Add ContinuationAdapter to coroutine tests helpers

It allows having the same Continuation implementations for different
API versions
This commit is contained in:
Denis Zharkov
2018-06-29 17:34:29 +03:00
parent f01e690f49
commit f23a0c8fea
33 changed files with 55 additions and 45 deletions
@@ -7,16 +7,14 @@ inline suspend fun foo(x: suspend () -> String) = x()
// FILE: box.kt
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
c.startCoroutine(object: helpers.ContinuationAdapter<Unit>() {
override fun resume(value: Unit) {
}
@@ -1,6 +1,7 @@
// IGNORE_BACKEND: JVM_IR
// FILE: inlined.kt
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
import kotlin.coroutines.experimental.*
@@ -33,7 +34,7 @@ import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
fun builder(c: suspend () -> Unit) {
val continuation = object: Continuation<Unit> {
val continuation = object: helpers.ContinuationAdapter<Unit>() {
override val context: CoroutineContext
get() = EmptyCoroutineContext
@@ -69,4 +70,4 @@ fun box(): String {
proceed()
if (!finished) return "resume on root continuation is not called"
return result
}
}
@@ -1,6 +1,7 @@
// IGNORE_BACKEND: JVM_IR
// FILE: inlined.kt
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
import kotlin.coroutines.experimental.*
@@ -31,7 +32,7 @@ import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
fun builder(c: suspend () -> Unit) {
val continuation = object: Continuation<Unit> {
val continuation = object: helpers.ContinuationAdapter<Unit>() {
override val context: CoroutineContext
get() = EmptyCoroutineContext
@@ -67,4 +68,4 @@ fun box(): String {
proceed()
if (!finished) return "resume on root continuation is not called"
return result
}
}
@@ -1,6 +1,7 @@
// FILE: inlined.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
@@ -17,6 +18,7 @@ suspend inline fun crossinlineMe2(crossinline c: suspend () -> Unit) {
import COROUTINES_PACKAGE.*
import COROUTINES_PACKAGE.intrinsics.*
import helpers.*
var result = "FAIL"
var i = 0
@@ -30,7 +32,7 @@ suspend fun suspendHere() = suspendCoroutine<Unit> { c ->
}
fun builder(c: suspend () -> Unit) {
val continuation = object: Continuation<Unit> {
val continuation = object: ContinuationAdapter<Unit>() {
override val context: CoroutineContext
get() = EmptyCoroutineContext
@@ -67,4 +69,4 @@ fun box(): String {
proceed()
if (!finished) return "resume on root continuation is not called"
return result
}
}