Added coroutine import to back-end test.

This commit is contained in:
Stanislav Erokhin
2016-12-15 03:13:39 +03:00
parent 0132f3eea7
commit e014fb7181
77 changed files with 153 additions and 0 deletions
+5
View File
@@ -2,6 +2,8 @@
// WITH_COROUTINES // WITH_COROUTINES
// NO_INTERCEPT_RESUME_TESTS // NO_INTERCEPT_RESUME_TESTS
// FILE: promise.kt // FILE: promise.kt
import kotlin.coroutines.*
class Promise<T>(private val executor: ((T) -> Unit) -> Unit) { class Promise<T>(private val executor: ((T) -> Unit) -> Unit) {
private var value: Any? = null private var value: Any? = null
private var thenList: MutableList<(T) -> Unit>? = mutableListOf() private var thenList: MutableList<(T) -> Unit>? = mutableListOf()
@@ -47,6 +49,8 @@ fun processQueue() {
} }
// FILE: await.kt // FILE: await.kt
import kotlin.coroutines.*
private var log = "" private var log = ""
private var inAwait = false private var inAwait = false
@@ -91,6 +95,7 @@ fun <T> asyncOperation(resultSupplier: () -> T) = Promise<T> { resolve ->
fun getLog() = log fun getLog() = log
// FILE: main.kt // FILE: main.kt
import kotlin.coroutines.*
private fun test() = async<String> { private fun test() = async<String> {
val o = await(asyncOperation { "O" }) val o = await(asyncOperation { "O" })
@@ -1,5 +1,6 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x -> } suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x -> }
@@ -1,5 +1,6 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x ->} suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x ->}
fun builder(c: suspend () -> Unit) { fun builder(c: suspend () -> Unit) {
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun <T> await(t: T): T = suspendWithCurrentContinuation { c -> suspend fun <T> await(t: T): T = suspendWithCurrentContinuation { c ->
c.resume(t) c.resume(t)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
// Does not work in JVM backend, probably due to bug. It's not clear which behaviour is right. // Does not work in JVM backend, probably due to bug. It's not clear which behaviour is right.
// TODO: fix the bug and enable for JVM backend // TODO: fix the bug and enable for JVM backend
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = false var result = false
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(a: String = "abc", i: Int = 2): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(a: String = "abc", i: Int = 2): String = suspendWithCurrentContinuation { x ->
x.resume(a + "#" + (i + 1)) x.resume(a + "#" + (i + 1))
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
var result = 0 var result = 0
class Controller { class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun <T> suspendHere(v: T): T = suspendWithCurrentContinuation { x -> suspend fun <T> suspendHere(v: T): T = suspendWithCurrentContinuation { x ->
x.resume(v) x.resume(v)
+1
View File
@@ -1,6 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// FULL_JDK // FULL_JDK
import kotlin.coroutines.*
fun box(): String { fun box(): String {
val x = gen().joinToString() val x = gen().joinToString()
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var exception: Throwable? = null var exception: Throwable? = null
val postponedActions = ArrayList<() -> Unit>() val postponedActions = ArrayList<() -> Unit>()
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit): String { fun builder(c: suspend () -> Unit): String {
var ok = false var ok = false
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var log = "" var log = ""
@@ -2,6 +2,8 @@
// WITH_COROUTINES // WITH_COROUTINES
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// NO_INTERCEPT_RESUME_TESTS // NO_INTERCEPT_RESUME_TESTS
import kotlin.coroutines.*
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED SUSPENDED
@@ -4,6 +4,8 @@
// CHECK_NOT_CALLED: suspendInline_61zpoe$ // CHECK_NOT_CALLED: suspendInline_61zpoe$
// CHECK_NOT_CALLED: suspendInline_6r51u9$ // CHECK_NOT_CALLED: suspendInline_6r51u9$
// CHECK_NOT_CALLED: suspendInline // CHECK_NOT_CALLED: suspendInline
import kotlin.coroutines.*
class Controller { class Controller {
fun withValue(v: String, x: Continuation<String>) { fun withValue(v: String, x: Continuation<String>) {
x.resume(v) x.resume(v)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = "" var globalResult = ""
var wasCalled = false var wasCalled = false
class Controller { class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var i = 0 var i = 0
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -1,6 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// WITH_REFLECT // WITH_REFLECT
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun runInstanceOf(): Boolean = suspendWithCurrentContinuation { x -> suspend fun runInstanceOf(): Boolean = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,6 +1,8 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,6 +1,8 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
@@ -1,6 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// NO_INTERCEPT_RESUME_TESTS // NO_INTERCEPT_RESUME_TESTS
import kotlin.coroutines.*
class Controller { class Controller {
var log = "" var log = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
+2
View File
@@ -1,6 +1,8 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
// WITH_CONTINUATION // WITH_CONTINUATION
import kotlin.coroutines.*
suspend fun <V> suspendHere(v: V): V = suspendWithCurrentContinuation { x -> suspend fun <V> suspendHere(v: V): V = suspendWithCurrentContinuation { x ->
x.resume(v) x.resume(v)
SUSPENDED SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var result = "" var result = ""
var ok = false var ok = false
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
SUSPENDED SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
SUSPENDED SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var ok = false var ok = false
var v = "fail" var v = "fail"
@@ -4,6 +4,8 @@
// FILE: controller.kt // FILE: controller.kt
package lib package lib
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
@@ -16,6 +18,7 @@ class Controller {
// MODULE: main(controller) // MODULE: main(controller)
// FILE: main.kt // FILE: main.kt
import lib.* import lib.*
import kotlin.coroutines.*
fun builder(c: suspend Controller.() -> Unit) { fun builder(c: suspend Controller.() -> Unit) {
c.startCoroutine(Controller(), EmptyContinuation) c.startCoroutine(Controller(), EmptyContinuation)
@@ -4,6 +4,8 @@
// FILE: controller.kt // FILE: controller.kt
package lib package lib
import kotlin.coroutines.*
@AllowSuspendExtensions @AllowSuspendExtensions
class Controller { class Controller {
suspend fun String.suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun String.suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -23,6 +25,7 @@ inline suspend fun Controller.inlineSuspendExtension(v: String) = v.inlineSuspen
// MODULE: main(controller) // MODULE: main(controller)
// FILE: main.kt // FILE: main.kt
import lib.* import lib.*
import kotlin.coroutines.*
suspend fun Controller.localSuspendExtension(v: String) = v.suspendHere() suspend fun Controller.localSuspendExtension(v: String) = v.suspendHere()
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var lastSuspension: Continuation<String>? = null var lastSuspension: Continuation<String>? = null
var result = "fail" var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var lastSuspension: Continuation<String>? = null var lastSuspension: Continuation<String>? = null
var result = "fail" var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var lastSuspension: Continuation<String>? = null var lastSuspension: Continuation<String>? = null
var result = "fail" var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var lastSuspension: Continuation<String>? = null var lastSuspension: Continuation<String>? = null
var result = "fail" var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = "" var globalResult = ""
var wasCalled = false var wasCalled = false
class Controller { class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
fun builder(c: suspend () -> Int): Int { fun builder(c: suspend () -> Int): Int {
var res = 0 var res = 0
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var cResult = 0 var cResult = 0
suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x -> suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var cResult = 0 var cResult = 0
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
SUSPENDED SUSPENDED
+2
View File
@@ -1,6 +1,8 @@
// IGNORE_BACKEND: JS // IGNORE_BACKEND: JS
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resumeWithException(RuntimeException("OK")) x.resumeWithException(RuntimeException("OK"))
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
SUSPENDED SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = throw RuntimeException("OK") suspend fun suspendHere(): String = throw RuntimeException("OK")
@@ -4,6 +4,8 @@
// CHECK_NOT_CALLED: suspendInline_61zpoe$ // CHECK_NOT_CALLED: suspendInline_61zpoe$
// CHECK_NOT_CALLED: suspendInline_6r51u9$ // CHECK_NOT_CALLED: suspendInline_6r51u9$
// CHECK_NOT_CALLED: suspendInline // CHECK_NOT_CALLED: suspendInline
import kotlin.coroutines.*
class Controller { class Controller {
suspend inline fun suspendInline(v: String): String = v suspend inline fun suspendInline(v: String): String = v
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere() = "OK" suspend fun suspendHere() = "OK"
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x ->
1 1
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = "" var globalResult = ""
suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x -> suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x ->
x.resume(v) x.resume(v)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = suspendThere() suspend fun suspendHere(): String = suspendThere()
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
@AllowSuspendExtensions @AllowSuspendExtensions
class Controller { class Controller {
suspend fun String.suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun String.suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x -> suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x ->
x.resume(v * 2) x.resume(v * 2)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
var i = 0 var i = 0
suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("K") x.resume("K")
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = "" var globalResult = ""
var wasCalled = false var wasCalled = false
class Controller { class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = "" var globalResult = ""
var wasCalled = false var wasCalled = false
class Controller { class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(v: String): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(v: String): String = suspendWithCurrentContinuation { x ->
x.resume(v) x.resume(v)
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = "" var globalResult = ""
var wasCalled = false var wasCalled = false
class Controller { class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
@@ -1,5 +1,7 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES // WITH_COROUTINES
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK") x.resume("OK")
@@ -644,6 +644,7 @@ public class KotlinTestUtils {
if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) { if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) {
testFiles.add(factory.createFile(null, testFiles.add(factory.createFile(null,
"CoroutineUtil.kt", "CoroutineUtil.kt",
"import kotlin.coroutines.*\n" +
"fun <T> handleResultContinuation(x: (T) -> Unit): Continuation<T> = object: Continuation<T> {\n" + "fun <T> handleResultContinuation(x: (T) -> Unit): Continuation<T> = object: Continuation<T> {\n" +
" override fun resumeWithException(exception: Throwable) {\n" + " override fun resumeWithException(exception: Throwable) {\n" +
" throw exception\n" + " throw exception\n" +