Implemented intrinsic <coroutineContext> + tests
This commit is contained in:
@@ -1309,6 +1309,16 @@ task coroutines_returnsUnit1(type: RunKonanTest) {
|
||||
source = "codegen/coroutines/returnsUnit1.kt"
|
||||
}
|
||||
|
||||
task coroutines_coroutineContext1(type: RunKonanTest) {
|
||||
goldValue = "EmptyCoroutineContext\n"
|
||||
source = "codegen/coroutines/coroutineContext1.kt"
|
||||
}
|
||||
|
||||
task coroutines_coroutineContext2(type: RunKonanTest) {
|
||||
goldValue = "EmptyCoroutineContext\n"
|
||||
source = "codegen/coroutines/coroutineContext2.kt"
|
||||
}
|
||||
|
||||
task AbstractMutableCollection(type: RunKonanTest) {
|
||||
expectedExitStatus = 0
|
||||
source = "runtime/collections/AbstractMutableCollection.kt"
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package codegen.coroutines.coroutineContext1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||
companion object : EmptyContinuation()
|
||||
override fun resume(value: Any?) {}
|
||||
override fun resumeWithException(exception: Throwable) { throw exception }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
builder { println(coroutineContext) }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package codegen.coroutines.coroutineContext2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||
companion object : EmptyContinuation()
|
||||
override fun resume(value: Any?) {}
|
||||
override fun resumeWithException(exception: Throwable) { throw exception }
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
suspend fun foo() = coroutineContext
|
||||
|
||||
@Test fun runTest() {
|
||||
builder { println(foo()) }
|
||||
}
|
||||
Reference in New Issue
Block a user