Support coroutines in Android box tests

This commit is contained in:
Mikhael Bogdanov
2018-10-24 11:07:16 +02:00
parent ae0b2405bc
commit 612ca87aa3
3 changed files with 17 additions and 7 deletions
@@ -3,13 +3,14 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
import helpers.ContinuationAdapter
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
fun runCustomLambdaAsCoroutine(e: Throwable? = null, x: (Continuation<String>) -> Any?): String {
var result = "fail"
var wasIntercepted = false
val c = (x as suspend () -> String).createCoroutine(object: helpers.ContinuationAdapter<String>() {
val c = (x as suspend () -> String).createCoroutine(object: ContinuationAdapter<String>() {
override fun resumeWithException(exception: Throwable) {
throw exception
}
@@ -27,7 +28,7 @@ fun runCustomLambdaAsCoroutine(e: Throwable? = null, x: (Continuation<String>) -
return null
}
override fun <T> interceptContinuation(continuation: Continuation<T>) = object : helpers.ContinuationAdapter<T>() {
override fun <T> interceptContinuation(continuation: Continuation<T>) = object : ContinuationAdapter<T>() {
override val context: CoroutineContext
get() = continuation.context