Support coroutines in Android box tests
This commit is contained in:
+12
-4
@@ -199,11 +199,17 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
continue
|
||||
}
|
||||
|
||||
val fullFileText = FileUtil.loadFile(file, true)
|
||||
val fullFileText = FileUtil.loadFile(file, true).let {
|
||||
it.replace("COROUTINES_PACKAGE", "kotlin.coroutines")
|
||||
}
|
||||
|
||||
if (fullFileText.contains("// WITH_COROUTINES")) {
|
||||
if (fullFileText.contains("kotlin.coroutines.experimental")) continue
|
||||
if (fullFileText.contains("// LANGUAGE_VERSION: 1.2")) continue
|
||||
}
|
||||
|
||||
//TODO support JvmPackageName
|
||||
if (fullFileText.contains("@file:JvmPackageName(")) continue
|
||||
// TODO: Support coroutines tests
|
||||
if (fullFileText.contains("// WITH_COROUTINES")) continue
|
||||
// TODO: Support jvm assertions
|
||||
if (fullFileText.contains("// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm")) continue
|
||||
// TODO: support JVM 8 test with D8
|
||||
@@ -248,7 +254,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
override fun create(fileName: String, text: String, directives: Map<String, String>): CodegenTestCase.TestFile {
|
||||
return CodegenTestCase.TestFile(fileName, text)
|
||||
}
|
||||
})
|
||||
}, false,
|
||||
"kotlin.coroutines"
|
||||
)
|
||||
|
||||
|
||||
private fun generateTestName(fileName: String): String {
|
||||
|
||||
+3
-2
@@ -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
|
||||
|
||||
|
||||
@@ -12,11 +12,12 @@ inline suspend fun foo(x: suspend () -> String) = x()
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
import helpers.ContinuationAdapter
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(object: helpers.ContinuationAdapter<Unit>() {
|
||||
c.startCoroutine(object: ContinuationAdapter<Unit>() {
|
||||
override fun resume(value: Unit) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user