Files
kotlin/compiler/testData/codegen/box/coroutines/lastUnitExpression.kt
Roman Artemev efec82c0eb Update test data
* add new tests for coroutines
 * add copy of some tests without dependency on stdlib
2018-08-08 18:33:41 +03:00

34 lines
747 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
import helpers.*
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
class Controller {
var ok = false
var v = "fail"
suspend fun suspendHere(v: String): Unit = suspendCoroutineUninterceptedOrReturn { x ->
this.v = v
x.resume(Unit)
COROUTINE_SUSPENDED
}
}
fun builder(c: suspend Controller.() -> Unit): String {
val controller = Controller()
c.startCoroutine(controller, handleResultContinuation {
controller.ok = true
})
if (!controller.ok) throw RuntimeException("Fail 1")
return controller.v
}
fun box(): String {
return builder {
suspendHere("OK")
}
}