Move compiler scripting tests to scripting plugin, remove unused funs

also remove some tests that are covered in the scripting-compiler
tests now.
Part of the cleanup to rewrite scripting to the new infrastructure.
This commit is contained in:
Ilya Chernikov
2020-04-03 23:02:40 +02:00
parent cf387ffad1
commit d863dc04e6
49 changed files with 334 additions and 279 deletions
@@ -0,0 +1 @@
@file: [TestAnno1 TestAnno2]
@@ -0,0 +1,4 @@
val v: Array<in String> = param[0]
val s = v[0]
System.out.println("first: $s, size: ${v.size}")
@@ -0,0 +1,4 @@
val v1 = myArgs[0]
val v2 = myArgs[1]
System.out.println("$v1 and $v2")
@@ -0,0 +1,2 @@
@file:Import("imp_cycle_2.req1.kts")
@@ -0,0 +1,2 @@
@file:Import("imp_cycle_1.req1.kts")
@@ -0,0 +1,2 @@
@file:Import("imp_leaf.req1.kts")
@@ -0,0 +1,2 @@
@file:Import("leaf.req1.kts")
@@ -0,0 +1,4 @@
@file:Import("leaf.req1.kts")
@file:Import("imp_leaf.req1.kts")
@@ -0,0 +1,4 @@
@file:Import("leaf.req1.kts")
@file:Import("leaf.req1.kts")
@@ -0,0 +1,3 @@
@file:Import("leaf_with_deps_1.req1.kts")
@file:Import("leaf_with_deps_2.req1.kts")
@@ -0,0 +1,2 @@
@file:Import("imp_self.req1.kts")
@@ -0,0 +1,3 @@
// nothing
@@ -0,0 +1,2 @@
@file:DependsOn("someDependency1.jar")
@@ -0,0 +1,2 @@
@file:DependsOn("someDependency2.jar")
@@ -0,0 +1,10 @@
// this script expected parameter num : Int
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
println("fib($n)=$v")
return v
}
println("num: $num")
val result = fib(num)
@@ -0,0 +1,11 @@
package kotlin.scripting.fibonacci
// this script expected parameter num : Int
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
println("fib($n)=$v")
return v
}
println("num: $num")
val result = fib(num)
@@ -0,0 +1,11 @@
// this script expected parameter param : class { val memberNum: Int }
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
println("fib($n)=$v")
return v
}
println("num: ${param.memberNum}")
val result = fib(param.memberNum)
@@ -0,0 +1,14 @@
import org.jetbrains.kotlin.scripting.compiler.test.*
// this script expected parameter num : Int
fun fib(n: Int): Int {
val v = fibCombine( { fib(it) }, n)
println("fib($n)=$v")
return v
}
println("num: $num")
val result = fib(num)
@@ -0,0 +1,16 @@
// this script expected parameter num : Int
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
println("fib($n)=$v")
return v
}
val hdr = "Num".decapitalize()
org.junit.Assert.assertTrue(true)
println("$hdr: $num")
val result = fib(num)
@@ -0,0 +1,16 @@
// this script expected parameter num : Int
@file:DependsOn("@{kotlin-stdlib}")
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
println("fib($n)=$v")
return v
}
val hdr = "Num".decapitalize()
println("$hdr: $num")
val result = fib(num)
@@ -0,0 +1,16 @@
// this script expected parameter num : Int
@file:DependsOnTwo(path2 = "@{kotlin-stdlib}")
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
println("fib($n)=$v")
return v
}
val hdr = "Num".decapitalize()
println("$hdr: $num")
val result = fib(num)
@@ -0,0 +1,13 @@
// Expecting two string parameters or nothing
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
println("fib($n)=$v")
return v
}
val num = if (args.size > 0) java.lang.Integer.parseInt(args[0]) else 4
val comment = if (args.size > 1) args[1] else "none"
println("num: $num ($comment)")
val result = fib(num)
@@ -0,0 +1,4 @@
import java.lang.RuntimeException
val k: Int? = param
if (k == null) System.out.println("Param is null") else throw RuntimeException("param is not null")
@@ -0,0 +1,5 @@
import java.lang.RuntimeException
val v: String? = param[0]
if (v == null) System.out.println("nullable") else RuntimeException("non nullable projection")
@@ -0,0 +1,4 @@
// this script expected parameter num: Int
val test = num + 10
println(test)
@@ -0,0 +1,11 @@
@file:DependsOn("@{kotlin-stdlib}")
fun main() {
error("my error")
}
fun a() {
main()
}
a()
@@ -0,0 +1,14 @@
fun checkInaccessible(name: String) {
try {
Class.forName(name)
throw AssertionError("Class should not be accessible from script via the class loader: $name")
}
catch (e: ClassNotFoundException) {
// OK
}
}
checkInaccessible("org.jetbrains.kotlin.config.KotlinCompilerVersion")
checkInaccessible("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
checkInaccessible("org.jetbrains.kotlin.preloading.Preloader")
print("OK")
@@ -0,0 +1,4 @@
val v1 = param1[0].toString()
val v2 = param2[0].toLong()
System.out.println("$v1 and $v2")
@@ -0,0 +1,2 @@
val num = 10 // check that we could declare property with the name as in the super class
println(num)