JS test: added inline tests

This commit is contained in:
Alexey Tsvetkov
2014-09-29 16:00:18 +04:00
committed by Zalim Bashorov
parent 987708680f
commit 3f2d4b31be
112 changed files with 4442 additions and 0 deletions
@@ -0,0 +1,60 @@
/*
* Copy of JVM-backend test
* Found at: compiler/testData/codegen/boxInline/tryCatchFinally/tryCatch.1.kt
*/
package foo
fun test1() : Int {
val inlineX = My(111)
var result = 0
val res = inlineX.perform<My, Int>{
try {
throw RuntimeException()
} catch (e: RuntimeException) {
result = -1
}
result
}
return result
}
fun test11() : Int {
val inlineX = My(111)
val res = inlineX.perform<My, Int>{
try {
throw RuntimeException()
} catch (e: RuntimeException) {
-1
}
}
return res
}
fun test2() : Int {
try {
val inlineX = My(111)
var result = 0
val res = inlineX.perform<My, Int>{
try {
throw RuntimeExceptionWithValue("-1")
} catch (e: RuntimeException) {
throw RuntimeExceptionWithValue("-2")
}
}
return result
} catch (e: RuntimeExceptionWithValue) {
return e.value.toInt2()!!
}
}
fun box(): String {
if (test1() != -1) return "test1: ${test1()}"
if (test11() != -1) return "test11: ${test11()}"
if (test2() != -2) return "test2: ${test2()}"
return "OK"
}
@@ -0,0 +1,16 @@
/*
* Copy of JVM-backend test
* Found at: compiler/testData/codegen/boxInline/tryCatchFinally/tryCatch.2.kt
*/
package foo
class My(val value: Int)
inline fun <T, R> T.perform(job: (T)-> R) : R {
return job(this)
}
inline fun String.toInt2() : Int = parseInt(this)
class RuntimeExceptionWithValue(val value: String) : RuntimeException()