Added a coroutine test

This commit is contained in:
Igor Chevdar
2018-12-19 14:28:42 +03:00
parent 1eaf2d2c42
commit 5afa44edea
6 changed files with 78 additions and 0 deletions
@@ -0,0 +1,33 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
import helpers.*
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
suspend fun suspendHere(): String {
var s: String? = null
val z: String = suspendCoroutineUninterceptedOrReturn { x ->
s = "zzz"
x.resume("OK")
COROUTINE_SUSPENDED
}
if (s != "zzz") return "fail"
return z
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var result = ""
builder {
result = suspendHere()
}
return result
}