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

33 lines
634 B
Kotlin
Vendored

// WITH_RUNTIME
// WITH_COROUTINES
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
var globalResult = ""
suspend fun suspendWithValue(v: String): String = suspendCoroutineOrReturn { 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
}