mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
36 lines
690 B
Kotlin
Vendored
36 lines
690 B
Kotlin
Vendored
// IGNORE_BACKEND: JVM_IR
|
|
// WITH_RUNTIME
|
|
// WITH_COROUTINES
|
|
// COMMON_COROUTINES_TEST
|
|
import helpers.*
|
|
import COROUTINES_PACKAGE.*
|
|
import COROUTINES_PACKAGE.intrinsics.*
|
|
|
|
var result = 0
|
|
|
|
class Controller {
|
|
suspend fun suspendHere(): String = suspendCoroutineUninterceptedOrReturn { x ->
|
|
result++
|
|
x.resume("OK")
|
|
COROUTINE_SUSPENDED
|
|
}
|
|
}
|
|
|
|
|
|
fun builder(c: suspend Controller.() -> Unit) {
|
|
c.startCoroutine(Controller(), EmptyContinuation)
|
|
}
|
|
|
|
fun box(): String {
|
|
|
|
for (i in 1..3) {
|
|
builder {
|
|
if (suspendHere() != "OK") throw RuntimeException("fail 1")
|
|
}
|
|
}
|
|
|
|
if (result != 3) return "fail 2: $result"
|
|
|
|
return "OK"
|
|
}
|