"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libraries/examples/kotlin-jsr223-local-example/src/test/kotlin/org/jetbrains/kotlin/script/jsr223/KotlinJsr223ScriptEngineIT.kt" between
kotlin-1.3.20.tar.gz and kotlin-1.3.21.tar.gz

About: Kotlin is a Java like statically typed programming language for the JVM, Android and the browser. Source code.

KotlinJsr223ScriptEngineIT.kt  (kotlin-1.3.20):KotlinJsr223ScriptEngineIT.kt  (kotlin-1.3.21)
skipping to change at line 236 skipping to change at line 236
Triple(t1 - t0, t2 - t1, t2 - t1) Triple(t1 - t0, t2 - t1, t2 - t1)
}.take(10).toList() }.take(10).toList()
val adjustedMaxDiff = times.sortedByDescending { (_, _, diff) -> diff }. drop(2).first() val adjustedMaxDiff = times.sortedByDescending { (_, _, diff) -> diff }. drop(2).first()
fun Long.ms() = TimeUnit.NANOSECONDS.toMillis(this) fun Long.ms() = TimeUnit.NANOSECONDS.toMillis(this)
Assert.assertTrue("eval in eval is too long: ${times.joinToString { "(${ it.first.ms()}, ${it.second.ms()})" }} (expecting no more than 5x difference)", 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 ) 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().scriptEngin
e
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) { fun assertThrows(exceptionClass: Class<*>, body: () -> Unit) {
try { try {
body() body()
Assert.fail("Expecting an exception of type ${exceptionClass.name}") Assert.fail("Expecting an exception of type ${exceptionClass.name}")
} }
catch (e: Throwable) { catch (e: Throwable) {
if (!exceptionClass.isAssignableFrom(e.javaClass)) { if (!exceptionClass.isAssignableFrom(e.javaClass)) {
Assert.fail("Expecting an exception of type ${exceptionClass.name} b ut got ${e.javaClass.name}") Assert.fail("Expecting an exception of type ${exceptionClass.name} b ut got ${e.javaClass.name}")
 End of changes. 1 change blocks. 
0 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)