Fix main-kts jsr223 direct bindings processing

Before the jsr context was configured only when a dependency or import
annotation is encountered, so direct properties mapping didn't work
without using any of the annotations. (It was implemented like this
as a workaround due to the problem with handlers composability, that was
fixed some time ago.)
This commit is contained in:
Ilya Chernikov
2019-09-03 16:48:11 +02:00
parent c5f9e0a399
commit 8989bfa235
2 changed files with 16 additions and 5 deletions
@@ -22,5 +22,15 @@ class MainKtsJsr223Test {
val res2 = engine.eval("x + 2")
Assert.assertEquals(5, res2)
}
@Test
fun testWithDirectBindings() {
val engine = ScriptEngineManager().getEngineByExtension("main.kts")!!
engine.put("z", 6)
val res1 = engine.eval("val x = 7")
Assert.assertNull(res1)
val res2 = engine.eval("z * x")
Assert.assertEquals(42, res2)
}
}