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
// NO_INTERCEPT_RESUME_TESTS
// FILE: promise.kt
import kotlin.coroutines.*
class Promise<T>(private val executor: ((T) -> Unit) -> Unit) {
private var value: Any? = null
private var thenList: MutableList<(T) -> Unit>? = mutableListOf()
@@ -47,6 +49,8 @@ fun processQueue() {
}
// FILE: await.kt
import kotlin.coroutines.*
private var log = ""
private var inAwait = false
@@ -91,6 +95,7 @@ fun <T> asyncOperation(resultSupplier: () -> T) = Promise<T> { resolve ->
fun getLog() = log
// FILE: main.kt
import kotlin.coroutines.*
private fun test() = async<String> {
val o = await(asyncOperation { "O" })
@@ -1,5 +1,6 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x -> }
@@ -1,5 +1,6 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): Any = suspendWithCurrentContinuation { x ->}
fun builder(c: suspend () -> Unit) {
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun <T> await(t: T): T = suspendWithCurrentContinuation { c ->
c.resume(t)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
// 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
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = false
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(a: String = "abc", i: Int = 2): String = suspendWithCurrentContinuation { x ->
x.resume(a + "#" + (i + 1))
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var result = 0
class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun <T> suspendHere(v: T): T = suspendWithCurrentContinuation { x ->
x.resume(v)
+1
View File
@@ -1,6 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// FULL_JDK
import kotlin.coroutines.*
fun box(): String {
val x = gen().joinToString()
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var exception: Throwable? = null
val postponedActions = ArrayList<() -> Unit>()
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
fun builder(c: suspend () -> Unit): String {
var ok = false
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var log = ""
@@ -2,6 +2,8 @@
// WITH_COROUTINES
// TARGET_BACKEND: JVM
// NO_INTERCEPT_RESUME_TESTS
import kotlin.coroutines.*
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
SUSPENDED
@@ -4,6 +4,8 @@
// CHECK_NOT_CALLED: suspendInline_61zpoe$
// CHECK_NOT_CALLED: suspendInline_6r51u9$
// CHECK_NOT_CALLED: suspendInline
import kotlin.coroutines.*
class Controller {
fun withValue(v: String, x: Continuation<String>) {
x.resume(v)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = ""
var wasCalled = false
class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var i = 0
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -1,6 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// WITH_REFLECT
import kotlin.coroutines.*
class Controller {
suspend fun runInstanceOf(): Boolean = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,6 +1,8 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TARGET_BACKEND: JVM
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,6 +1,8 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TARGET_BACKEND: JVM
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit)
@@ -1,6 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
// NO_INTERCEPT_RESUME_TESTS
import kotlin.coroutines.*
class Controller {
var log = ""
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
+2
View File
@@ -1,6 +1,8 @@
// WITH_RUNTIME
// WITH_COROUTINES
// WITH_CONTINUATION
import kotlin.coroutines.*
suspend fun <V> suspendHere(v: V): V = suspendWithCurrentContinuation { x ->
x.resume(v)
SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var result = ""
var ok = false
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var ok = false
var v = "fail"
@@ -4,6 +4,8 @@
// FILE: controller.kt
package lib
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
@@ -16,6 +18,7 @@ class Controller {
// MODULE: main(controller)
// FILE: main.kt
import lib.*
import kotlin.coroutines.*
fun builder(c: suspend Controller.() -> Unit) {
c.startCoroutine(Controller(), EmptyContinuation)
@@ -4,6 +4,8 @@
// FILE: controller.kt
package lib
import kotlin.coroutines.*
@AllowSuspendExtensions
class Controller {
suspend fun String.suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -23,6 +25,7 @@ inline suspend fun Controller.inlineSuspendExtension(v: String) = v.inlineSuspen
// MODULE: main(controller)
// FILE: main.kt
import lib.*
import kotlin.coroutines.*
suspend fun Controller.localSuspendExtension(v: String) = v.suspendHere()
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var lastSuspension: Continuation<String>? = null
var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var lastSuspension: Continuation<String>? = null
var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var lastSuspension: Continuation<String>? = null
var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var lastSuspension: Continuation<String>? = null
var result = "fail"
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = ""
var wasCalled = false
class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
fun builder(c: suspend () -> Int): Int {
var res = 0
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var cResult = 0
suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var cResult = 0
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
SUSPENDED
+2
View File
@@ -1,6 +1,8 @@
// IGNORE_BACKEND: JS
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resumeWithException(RuntimeException("OK"))
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
SUSPENDED
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = throw RuntimeException("OK")
@@ -4,6 +4,8 @@
// CHECK_NOT_CALLED: suspendInline_61zpoe$
// CHECK_NOT_CALLED: suspendInline_6r51u9$
// CHECK_NOT_CALLED: suspendInline
import kotlin.coroutines.*
class Controller {
suspend inline fun suspendInline(v: String): String = v
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere() = "OK"
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x ->
1
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = ""
suspend fun suspendWithValue(v: String): String = suspendWithCurrentContinuation { x ->
x.resume(v)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = suspendThere()
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
@AllowSuspendExtensions
class Controller {
suspend fun String.suspendHere(): String = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(v: Int): Int = suspendWithCurrentContinuation { x ->
x.resume(v * 2)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
var i = 0
suspend fun suspendHere(): Int = suspendWithCurrentContinuation { x ->
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("K")
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = ""
var wasCalled = false
class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = ""
var wasCalled = false
class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(v: String): String = suspendWithCurrentContinuation { x ->
x.resume(v)
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var globalResult = ""
var wasCalled = false
class Controller {
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
@@ -1,5 +1,7 @@
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
class Controller {
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
@@ -644,6 +644,7 @@ public class KotlinTestUtils {
if (isDirectiveDefined(expectedText, "WITH_COROUTINES")) {
testFiles.add(factory.createFile(null,
"CoroutineUtil.kt",
"import kotlin.coroutines.*\n" +
"fun <T> handleResultContinuation(x: (T) -> Unit): Continuation<T> = object: Continuation<T> {\n" +
" override fun resumeWithException(exception: Throwable) {\n" +
" throw exception\n" +