From 779a5606a768ab77944451454ec13fa03e1e0e07 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 29 Dec 2023 05:11:50 +0100 Subject: [PATCH] add unittest for aa%bb (without space) to be parsed correctly as modulo, not directive --- compiler/test/ast/TestVariousCompilerAst.kt | 18 ++++++++++++++++++ docs/source/todo.rst | 11 ++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/compiler/test/ast/TestVariousCompilerAst.kt b/compiler/test/ast/TestVariousCompilerAst.kt index d6a8681b1..e9249be71 100644 --- a/compiler/test/ast/TestVariousCompilerAst.kt +++ b/compiler/test/ast/TestVariousCompilerAst.kt @@ -14,6 +14,7 @@ import prog8.ast.statements.VarDecl import prog8.code.core.DataType import prog8.code.core.Position import prog8.code.target.C64Target +import prog8.code.target.Cx16Target import prog8.code.target.VMTarget import prog8tests.helpers.ErrorReporterForTests import prog8tests.helpers.compileText @@ -493,5 +494,22 @@ main { (right2.left as? IdentifierReference)?.nameInSource shouldBe listOf("x") (right2.right as? NumericLiteral)?.number shouldBe 10.0 } + + test("modulo is not directive") { + val src=""" +main { + sub start() { + ubyte bb1 = 199 + ubyte bb2 = 12 + ubyte @shared bb3 = bb1%bb2 + } +}""" + + val result=compileText(Cx16Target(), optimize=false, src, writeAssembly=false)!! + val st = result.compilerAst.entrypoint.statements + st.size shouldBe 6 + val value = (st[5] as Assignment).value as BinaryExpression + value.operator shouldBe "%" + } }) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 67d3d9c5d..44332bfdc 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,17 +2,10 @@ TODO ==== -- add unittest for aa%bb (without space) to be parsed correctly as modulo - ubyte bb1 = 199 - ubyte bb2 = 12 - ubyte bb3 = bb1%bb2 - txt.print_ub(bb3) - - -- fix bitshift.p8 -- make internalCast() not complain anymore about signed <-> unsigned conversions - add crc8 and crc16 and crc32 to math - fix crc* bench routines to no longer depend on the kernal rom version (use a bin file) +- make internalCast() not complain anymore about signed <-> unsigned conversions +- fix bitshift.p8 - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....