Files
kotlin/compiler/testData/codegen/box/coroutines/beginWithExceptionNoHandleException.kt
Denis Zharkov d92c403f9e Move helpers for coroutine tests in separate package
It will help to skip their content when rendering bytecode listing
for box tests
2017-05-05 14:01:50 +03:00

35 lines
757 B
Kotlin
Vendored

// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
suspend fun suspendHere(): Any = suspendCoroutineOrReturn { 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
}