[minor] scripting tests improvements

This commit is contained in:
Ilya Chernikov
2020-10-08 19:22:26 +02:00
parent af7102a586
commit 62b9d87bfc
2 changed files with 9 additions and 4 deletions
@@ -6,6 +6,7 @@
package kotlin.script.experimental.jvmhost.test
import org.junit.Test
import kotlin.script.experimental.api.EvaluationResult
import kotlin.script.experimental.api.ResultWithDiagnostics
import kotlin.script.experimental.api.implicitReceivers
import kotlin.script.experimental.api.providedProperties
@@ -21,7 +22,7 @@ class ConstructorArgumentsOrderTest {
assertTrue(
res is ResultWithDiagnostics.Success,
"test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}"
"test failed:\n ${res.render()}"
)
}
@@ -33,7 +34,7 @@ class ConstructorArgumentsOrderTest {
assertTrue(
res is ResultWithDiagnostics.Success,
"test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}"
"test failed:\n ${res.render()}"
)
}
@@ -46,7 +47,10 @@ class ConstructorArgumentsOrderTest {
assertTrue(
res is ResultWithDiagnostics.Success,
"test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}"
"test failed:\n ${res.render()}"
)
}
private fun ResultWithDiagnostics<EvaluationResult>.render() =
reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception!!.printStackTrace()}" }
}
@@ -66,7 +66,8 @@ class ScriptingHostTest : TestCase() {
@Test
fun testValueResult() {
val resVal = evalScriptWithResult("42") as ResultValue.Value
val evalScriptWithResult = evalScriptWithResult("42")
val resVal = evalScriptWithResult as ResultValue.Value
Assert.assertEquals(42, resVal.value)
Assert.assertEquals("\$\$result", resVal.name)
Assert.assertEquals("kotlin.Int", resVal.type)