fix #80 edge case !isSomething() bug fixed

+String.last()
This commit is contained in:
sergeych committed 2025-12-06 15:07:38 +01:00
1 parent f616326383
commit 2e96d75b9f
4 files changed
+60 -4

No files matched your search

@@ -4012,4 +4012,41 @@ class ScriptTest {
""".trimIndent()).decodeSerializable<TestJson4>()
assertEquals( TestJson4(TestEnum.One), x)
}
@Test
fun testLogicalNot() = runTest {
eval("""
val vf = false
fun f() { false }
assert( !false )
assert( !vf )
assert( !f() )
val vt = true
fun ft() { true }
if( !true )
throw "impossible"
if( !ft() )
throw "impossible"
if( !vt )
throw "impossible"
// real world sample
fun isSignedByAdmin() {
// just ok
true
}
fun requireAdmin() {
// this caused compilation error:
if( !isSignedByAdmin() )
throw "Admin signature required"
}
""".trimIndent()
)
}
}