Fix parameter index on IR script generation in REPL scenario
Before it, the wrong index lead to the validation error when repl script definition had c-tor parameters (see test)
This commit is contained in:
+22
@@ -16,6 +16,8 @@ import kotlin.script.experimental.jvm.BasicJvmReplEvaluator
|
||||
import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
|
||||
import kotlin.script.experimental.jvm.updateClasspath
|
||||
import kotlin.script.experimental.jvm.util.classpathFromClass
|
||||
import kotlin.script.experimental.jvmhost.createJvmScriptDefinitionFromTemplate
|
||||
import kotlin.script.templates.standard.ScriptTemplateWithArgs
|
||||
|
||||
class ReplTest : TestCase() {
|
||||
|
||||
@@ -231,6 +233,26 @@ class ReplTest : TestCase() {
|
||||
assertTrue("Refinement handler on annotation is not invoked", handlerInvoked)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDefinitionWithConstructorArgs() {
|
||||
val scriptDef = createJvmScriptDefinitionFromTemplate<ScriptTemplateWithArgs>(
|
||||
evaluation = {
|
||||
constructorArgs(arrayOf("a"))
|
||||
}
|
||||
)
|
||||
|
||||
checkEvaluateInRepl(
|
||||
sequenceOf(
|
||||
"args[0]",
|
||||
"res0+args[0]",
|
||||
"res1+args[0]"
|
||||
),
|
||||
sequenceOf("a", "aa", "aaa"),
|
||||
scriptDef.compilationConfiguration,
|
||||
scriptDef.evaluationConfiguration
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun evaluateInRepl(
|
||||
snippets: Sequence<String>,
|
||||
|
||||
Reference in New Issue
Block a user