[minor] scripting tests improvements
This commit is contained in:
+7
-3
@@ -6,6 +6,7 @@
|
|||||||
package kotlin.script.experimental.jvmhost.test
|
package kotlin.script.experimental.jvmhost.test
|
||||||
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import kotlin.script.experimental.api.EvaluationResult
|
||||||
import kotlin.script.experimental.api.ResultWithDiagnostics
|
import kotlin.script.experimental.api.ResultWithDiagnostics
|
||||||
import kotlin.script.experimental.api.implicitReceivers
|
import kotlin.script.experimental.api.implicitReceivers
|
||||||
import kotlin.script.experimental.api.providedProperties
|
import kotlin.script.experimental.api.providedProperties
|
||||||
@@ -21,7 +22,7 @@ class ConstructorArgumentsOrderTest {
|
|||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
res is ResultWithDiagnostics.Success,
|
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(
|
assertTrue(
|
||||||
res is ResultWithDiagnostics.Success,
|
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(
|
assertTrue(
|
||||||
res is ResultWithDiagnostics.Success,
|
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()}" }
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -66,7 +66,8 @@ class ScriptingHostTest : TestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testValueResult() {
|
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(42, resVal.value)
|
||||||
Assert.assertEquals("\$\$result", resVal.name)
|
Assert.assertEquals("\$\$result", resVal.name)
|
||||||
Assert.assertEquals("kotlin.Int", resVal.type)
|
Assert.assertEquals("kotlin.Int", resVal.type)
|
||||||
|
|||||||
Reference in New Issue
Block a user