Add support for custom script compilation and execution to maven plugin, add simple test, relevant refactorings on the compiler side
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.scripts
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.messages.*
|
||||
import org.jetbrains.kotlin.cli.common.tryConstructScriptClass
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler
|
||||
@@ -43,7 +44,7 @@ class ScriptTest : KtUsefulTestCase() {
|
||||
val aClass = compileScript("fib_std.kts", StandardScriptDefinition)
|
||||
Assert.assertNotNull(aClass)
|
||||
val out = captureOut {
|
||||
val anObj = KotlinToJVMBytecodeCompiler.tryConstructClassPub(aClass!!, listOf("4", "comment"))
|
||||
val anObj = tryConstructScriptClass(aClass!!, listOf("4", "comment"))
|
||||
Assert.assertNotNull(anObj)
|
||||
}
|
||||
Assert.assertEquals(NUM_4_LINE + " (comment)" + FIB_SCRIPT_OUTPUT_TAIL, out)
|
||||
@@ -54,7 +55,7 @@ class ScriptTest : KtUsefulTestCase() {
|
||||
val aClass = compileScript("fib_std.kts", StandardScriptDefinition)
|
||||
Assert.assertNotNull(aClass)
|
||||
val out = captureOut {
|
||||
val anObj = KotlinToJVMBytecodeCompiler.tryConstructClassPub(aClass!!, emptyList())
|
||||
val anObj = tryConstructScriptClass(aClass!!, emptyList())
|
||||
Assert.assertNotNull(anObj)
|
||||
}
|
||||
Assert.assertEquals(NUM_4_LINE + " (none)" + FIB_SCRIPT_OUTPUT_TAIL, out)
|
||||
@@ -67,7 +68,7 @@ class ScriptTest : KtUsefulTestCase() {
|
||||
val aClass = compileScript("fib_std.kts", StandardScriptDefinition, saveClassesDir = tmpdir)
|
||||
Assert.assertNotNull(aClass)
|
||||
val out1 = captureOut {
|
||||
val anObj = KotlinToJVMBytecodeCompiler.tryConstructClassPub(aClass!!, emptyList())
|
||||
val anObj = tryConstructScriptClass(aClass!!, emptyList())
|
||||
Assert.assertNotNull(anObj)
|
||||
}
|
||||
Assert.assertEquals(NUM_4_LINE + " (none)" + FIB_SCRIPT_OUTPUT_TAIL, out1)
|
||||
@@ -75,7 +76,7 @@ class ScriptTest : KtUsefulTestCase() {
|
||||
val aClassSaved = savedClassLoader.loadClass(aClass.name)
|
||||
Assert.assertNotNull(aClassSaved)
|
||||
val out2 = captureOut {
|
||||
val anObjSaved = KotlinToJVMBytecodeCompiler.tryConstructClassPub(aClassSaved!!, emptyList())
|
||||
val anObjSaved = tryConstructScriptClass(aClassSaved!!, emptyList())
|
||||
Assert.assertNotNull(anObjSaved)
|
||||
}
|
||||
Assert.assertEquals(NUM_4_LINE + " (none)" + FIB_SCRIPT_OUTPUT_TAIL, out2)
|
||||
@@ -134,4 +135,4 @@ class ScriptTest : KtUsefulTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
class TestParamClass(val memberNum: Int)
|
||||
class TestParamClass(@Suppress("unused") val memberNum: Int)
|
||||
Reference in New Issue
Block a user