fix #22 test throw from kotlin code
This commit is contained in:
parent
bb862e6cb5
commit
59a76efdce
@ -1854,4 +1854,26 @@ class ScriptTest {
|
|||||||
""".trimIndent())
|
""".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())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user