Files
kotlin/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt
Roman Artemev c62e4b4fcf [JS IR BE] Support coroutines
* Move FinallyBlockLowering to common part
* Fix catching of dynamic exception
* Fix bridges for suspend functions
* Disable explicit cast to Unit
* Run lowering per module
* Update some test data
2018-08-08 18:33:39 +03:00

37 lines
798 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
import helpers.*
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
suspend fun suspendHere(): Any = suspendCoroutineUninterceptedOrReturn { x ->}
fun builder(c: suspend () -> Unit) {
try {
c.createCoroutine(EmptyContinuation).resumeWithException(RuntimeException("OK"))
}
catch(e: Exception) {
if (e?.message != "OK") {
throw RuntimeException("Unexpected result: ${e?.message}")
}
return
}
throw RuntimeException("Exception must be thrown above")
}
fun box(): String {
var result = "OK"
builder {
suspendHere()
result = "fail 1"
}
builder {
result = "fail 2"
}
return result
}