Replace a couple of usages of suspendCoroutineOrReturn in tests

This commit is contained in:
Denis Zharkov
2018-07-04 18:40:14 +03:00
parent e753e0978f
commit a23ce42c80
2 changed files with 22 additions and 10 deletions
@@ -9,19 +9,24 @@ import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
class Controller {
suspend fun suspendHere() = suspendCoroutineOrReturn<String> { x ->
x.resume("OK")
COROUTINE_SUSPENDED
var callback: () -> Unit = {}
suspend fun suspendHere() = suspendCoroutine<String> { x ->
callback = {
x.resume("OK")
}
}
}
fun builder(c: suspend Controller.() -> Unit) {
c.startCoroutine(Controller(), object : helpers.ContinuationAdapter<Unit>() {
val controller = Controller()
c.startCoroutine(controller, object : helpers.ContinuationAdapter<Unit>() {
override val context: CoroutineContext = EmptyCoroutineContext
override fun resume(value: Unit) {}
override fun resumeWithException(exception: Throwable) {}
})
controller.callback()
}
// FILE: B.kt