fix #22 test throw from kotlin code

This commit is contained in:
Sergey Chernov 2025-06-13 07:51:42 +04:00
parent bb862e6cb5
commit 59a76efdce

View File

@ -1854,4 +1854,26 @@ class ScriptTest {
""".trimIndent())
}
@Test
fun testThrowFromKotlin() = runTest {
val c = Context()
c.addFn("callThrow") {
raiseArgumentError("fromKotlin")
}
c.eval("""
val result = try {
callThrow()
"fail"
}
catch(e) {
println("caught:"+e)
println(e.message)
assert( e is IllegalArgumentException )
assertEquals("fromKotlin", e.message)
"ok"
}
assertEquals(result, "ok")
""".trimIndent())
}
}