Files
kotlin/compiler/testData/codegen/box/coroutines/statementLikeLastExpression.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

35 lines
675 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
import helpers.*
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
var globalResult = ""
suspend fun suspendWithValue(v: String): String = suspendCoroutineUninterceptedOrReturn { x ->
x.resume(v)
COROUTINE_SUSPENDED
}
fun builder(c: suspend () -> String) {
c.startCoroutine(handleResultContinuation {
globalResult = it
})
}
fun box(): String {
var condition = true
builder {
if (condition) {
suspendWithValue("OK")
} else {
suspendWithValue("fail 1")
}
}
return globalResult
}