Create standard script definition from standard template

Now each script without specified template has a StandardSriptTemplate
class as a base one. This allows to generalize script codegen and
resolve.
This commit is contained in:
Mikhail Zarechenskiy
2016-09-12 01:24:18 +03:00
parent d69e7c7aec
commit 0ba2d374bc
14 changed files with 39 additions and 39 deletions
@@ -37,6 +37,7 @@ import java.lang.Exception
import java.net.URLClassLoader
import java.util.concurrent.Future
import kotlin.reflect.KClass
import kotlin.script.StandardScriptTemplate
// TODO: the contetnts of this file should go into ScriptTest.kt and replace appropriate xml-based functionality,
// as soon as the the latter is removed from the codebase
@@ -126,6 +127,13 @@ class ScriptTest2 {
aClass!!.getConstructor(Array<Array<in String>>::class.java).newInstance(arrayOf(arrayOf("one"), arrayOf("two")))
}
@Test
fun testScriptWithStandardTemplate() {
val aClass = compileScript("fib_std.kts", StandardScriptTemplate::class, runIsolated = false)
Assert.assertNotNull(aClass)
aClass!!.getConstructor(Array<String>::class.java).newInstance(arrayOf("4", "other"))
}
private fun compileScript(
scriptPath: String,
scriptBase: KClass<out Any>,