tests: Update external tests (1.1.2-dev-393)

This commit is contained in:
Ilya Matveev
2017-03-13 12:38:08 +03:00
committed by ilmat192
parent ac56fccb15
commit bc074e6d39
3178 changed files with 22396 additions and 696 deletions
@@ -0,0 +1,19 @@
// FILE: 1.kt
inline fun <R> performWithFinally(finally: () -> R) : R {
try {
throw RuntimeException("1")
} catch (e: RuntimeException) {
throw RuntimeException("2")
} finally {
return finally()
}
}
// FILE: 2.kt
inline fun test2Inline() = performWithFinally { "OK" }
fun box(): String {
return test2Inline()
}
@@ -0,0 +1,66 @@
// IGNORE_BACKEND: NATIVE
// FILE: 1.kt
class My(val value: Int)
inline fun <T, R> T.perform(job: (T)-> R) : R {
return job(this)
}
public inline fun String.toInt2() : Int = java.lang.Integer.parseInt(this)
// FILE: 2.kt
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 RuntimeException("-1")
} catch (e: RuntimeException) {
throw RuntimeException("-2")
}
}
return result
} catch (e: RuntimeException) {
return e.message!!.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,132 @@
// IGNORE_BACKEND: NATIVE
// FILE: 1.kt
class My(val value: Int)
inline fun <T, R> T.performWithFail(job: (T)-> R, failJob : (T) -> R) : R {
try {
return job(this)
} catch (e: RuntimeException) {
return failJob(this)
}
}
inline fun <T, R> T.performWithFail2(job: (T)-> R, failJob : (e: RuntimeException, T) -> R) : R {
try {
return job(this)
} catch (e: RuntimeException) {
return failJob(e, this)
}
}
public inline fun String.toInt2() : Int = java.lang.Integer.parseInt(this)
// FILE: 2.kt
fun test1(): Int {
val res = My(111).performWithFail<My, Int>(
{
throw RuntimeException()
}, {
it.value
})
return res
}
fun test11(): Int {
val res = My(111).performWithFail2<My, Int>(
{
try {
throw RuntimeException("1")
} catch (e: RuntimeException) {
throw RuntimeException("2")
}
},
{ ex, thizz ->
if (ex.message == "2") {
thizz.value
} else {
-11111
}
})
return res
}
fun test2(): Int {
val res = My(111).performWithFail<My, Int>(
{
it.value
},
{
it.value + 1
})
return res
}
fun test22(): Int {
val res = My(111).performWithFail2<My, Int>(
{
try {
throw RuntimeException("1")
} catch (e: RuntimeException) {
it.value
111
}
},
{ ex, thizz ->
-11111
})
return res
}
fun test3(): Int {
try {
val res = My(111).performWithFail<My, Int>(
{
throw RuntimeException("-1")
}, {
throw RuntimeException("-2")
})
return res
} catch (e: RuntimeException) {
return e.message?.toInt2()!!
}
}
fun test33(): Int {
try {
val res = My(111).performWithFail2<My, Int>(
{
try {
throw RuntimeException("-1")
} catch (e: RuntimeException) {
throw RuntimeException("-2")
}
},
{ ex, thizz ->
if (ex.message == "-2") {
throw RuntimeException("-3")
} else {
-11111
}
})
return res
} catch (e: RuntimeException) {
return e.message!!.toInt2()!!
}
}
fun box(): String {
if (test1() != 111) return "test1: ${test1()}"
if (test11() != 111) return "test11: ${test11()}"
if (test2() != 111) return "test2: ${test2()}"
if (test22() != 111) return "test22: ${test22()}"
if (test3() != -2) return "test3: ${test3()}"
if (test33() != -3) return "test33: ${test33()}"
return "OK"
}
@@ -0,0 +1,101 @@
// IGNORE_BACKEND: NATIVE
// FILE: 1.kt
// WITH_RUNTIME
class My(val value: Int)
inline fun <T, R> T.performWithFinally(job: (T)-> R, finally: (T) -> R) : R {
try {
return job(this)
} finally {
return finally(this)
}
}
inline fun <T, R> T.performWithFailFinally(job: (T)-> R, failJob : (e: RuntimeException, T) -> R, finally: (T) -> R) : R {
try {
return job(this)
} catch (e: RuntimeException) {
return failJob(e, this)
} finally {
return finally(this)
}
}
inline fun String.toInt2() : Int = java.lang.Integer.parseInt(this)
// FILE: 2.kt
fun test1(): Int {
var res = My(111).performWithFinally<My, Int>(
{
1
}, {
it.value
})
return res
}
fun test11(): Int {
var result = -1;
val res = My(111).performWithFinally<My, Int>(
{
try {
result = it.value
throw RuntimeException("1")
} catch (e: RuntimeException) {
++result
throw RuntimeException("2")
}
},
{
++result
})
return res
}
fun test2(): Int {
var res = My(111).performWithFinally<My, Int>(
{
throw RuntimeException("1")
},
{
it.value
})
return res
}
fun test3(): Int {
try {
var result = -1;
val res = My(111).performWithFailFinally<My, Int>(
{
result = it.value;
throw RuntimeException("-1")
},
{ e, z ->
++result
throw RuntimeException("-2")
},
{
++result
})
return res
} catch (e: RuntimeException) {
return e.message?.toInt()!!
}
}
fun box(): String {
if (test1() != 111) return "test1: ${test1()}"
if (test11() != 113) return "test11: ${test11()}"
if (test2() != 111) return "test2: ${test2()}"
if (test3() != 113) return "test3: ${test3()}"
return "OK"
}