Restore returning of functional types from repl eval

add tests for the broken case as well for the return value representation
#KT-29490 fixed
This commit is contained in:
Ilya Chernikov
2019-01-28 10:47:01 +01:00
parent 52464fd103
commit f125600af1
4 changed files with 22 additions and 1 deletions
@@ -233,6 +233,17 @@ obj
Assert.assertTrue("eval in eval is too long: ${times.joinToString { "(${it.first.ms()}, ${it.second.ms()})" }} (expecting no more than 5x difference)",
adjustedMaxDiff.third < 20 /* assuming it measurement error */ || adjustedMaxDiff.first * 5 > adjustedMaxDiff.second )
}
@Test
fun `kotlin script evaluation should support functional return types`() {
val scriptEngine = KotlinJsr223JvmLocalScriptEngineFactory().scriptEngine
val script = "{1 + 2}"
val result = scriptEngine.eval(script)
Assert.assertTrue(result is Function0<*>)
Assert.assertEquals(3, (result as Function0<*>).invoke())
}
}
fun assertThrows(exceptionClass: Class<*>, body: () -> Unit) {