@@ -3,10 +3,9 @@ package prog8tests.ast
33import io.kotest.core.spec.style.FunSpec
44import io.kotest.matchers.shouldBe
55import io.kotest.matchers.shouldNotBe
6+ import io.kotest.matchers.types.instanceOf
67import prog8.ast.IFunctionCall
7- import prog8.ast.expressions.BinaryExpression
8- import prog8.ast.expressions.IdentifierReference
9- import prog8.ast.expressions.StringLiteral
8+ import prog8.ast.expressions.*
109import prog8.ast.statements.Assignment
1110import prog8.ast.statements.InlineAssembly
1211import prog8.ast.statements.VarDecl
@@ -179,5 +178,28 @@ main {
179178 val stmts = result.program.entrypoint.statements
180179 stmts.size shouldBe 9
181180 }
181+
182+ test("alternative notation for negative containment check") {
183+ val src="""
184+ main {
185+ sub start() {
186+ ubyte[] array=[1,2,3]
187+ cx16.r0L = not (3 in array)
188+ cx16.r1L = 3 not in array
189+ }
190+ }
191+ """
192+ val result = compileText(C64Target (), optimize=false, src, writeAssembly=false)!!
193+ val stmts = result.program.entrypoint.statements
194+ stmts.size shouldBe 3
195+ val value1 = (stmts[1] as Assignment ).value as BinaryExpression
196+ val value2 = (stmts[2] as Assignment ).value as BinaryExpression
197+ value1.operator shouldBe " =="
198+ value1.left shouldBe instanceOf<ContainmentCheck >()
199+ (value1.right as NumericLiteral ).number shouldBe 0.0
200+ value2.operator shouldBe " =="
201+ value2.left shouldBe instanceOf<ContainmentCheck >()
202+ (value2.right as NumericLiteral ).number shouldBe 0.0
203+ }
182204})
183205
0 commit comments