Add special tests for interceptRun support

Basically they're built upon basic coroutine tests, but for each of them
different interceptResume implementation are injected
(currently there are 12 of them).

It might be more simple just to generated additional testData, but I see this
more problematic in a sense of further maintenance

Note that all tests add idempotent 'interceptRun' operators,
which just execute given lambda in the current thread

 #KT-14891 Fixed
This commit is contained in:
Denis Zharkov
2016-11-22 12:02:20 +03:00
parent 5ff71e1330
commit 01c21e218a
84 changed files with 780 additions and 37 deletions
@@ -7,6 +7,8 @@ class Controller {
}
suspend fun suspendHere(x: Continuation<Any>) {}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -1,6 +1,8 @@
// WITH_RUNTIME
class Controller {
suspend fun suspendHere(x: Continuation<Any>) {}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -7,6 +7,8 @@ class Controller {
suspend fun <T> await(t: T, c: Continuation<T>) {
c.resume(t)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): String {
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -48,4 +49,4 @@ fun box(): String {
if (value != "AC!ED!@*finally.") return "fail: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -44,4 +45,4 @@ fun box(): String {
if (value != "OQKQ.") return "fail: break inner loop: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -35,4 +36,4 @@ fun box(): String {
if (value != "1;2;3;.") return "fail: suspend in do..while body: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -25,4 +26,4 @@ fun box(): String {
if (value != "OK.") return "fail: suspend in for body: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -24,4 +25,4 @@ fun box(): String {
if (value != "OK.") return "fail: suspend in for body: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -69,4 +70,4 @@ fun box(): String {
if (value != "O;;") return "fail: suspend in then branch without else: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
// 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
@@ -41,4 +42,4 @@ fun box(): String {
if (value != "suspend(OK);finally;return(OK);") return "fail: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
// TODO: fix bug in JVM backend and remove this directive
// TARGET_BACKEND: JS
@@ -31,4 +32,4 @@ fun box(): String {
if (value != "A;[B][C]!") return "fail: suspend as if condition: $value"
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -45,4 +46,4 @@ fun box(): String {
}
return "OK"
}
}
@@ -1,4 +1,5 @@
// WITH_RUNTIME
// NO_INTERCEPT_RESUME_TESTS
class Controller {
var result = ""
@@ -35,4 +36,4 @@ fun box(): String {
if (value != "1;2;3;.") return "fail: suspend in while body: $value"
return "OK"
}
}
@@ -7,6 +7,8 @@ class Controller {
fun foo() {
result = true
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(a: String = "abc", i: Int = 2, x: Continuation<String>) {
x.resume(a + "#" + (i + 1))
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -5,6 +5,8 @@ class Controller {
result++
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
@@ -2,6 +2,8 @@ class Controller {
suspend fun <T> suspendHere(v: T, x: Continuation<T>) {
x.resume(v)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
+2
View File
@@ -51,4 +51,6 @@ class GeneratorController<T>() : AbstractIterator<T>() {
operator fun handleResult(result: Unit, c: Continuation<Nothing>) {
done()
}
// INTERCEPT_RESUME_PLACEHOLDER
}
@@ -26,6 +26,8 @@ class Controller {
postponedActions.removeAt(0)
}
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -4,6 +4,8 @@ class Controller {
operator fun handleResult(u: Unit, v: Continuation<Nothing>) {
ok = true
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): String {
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: Unit, y: Continuation<Nothing>) {
isCompleted = true
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -9,6 +9,8 @@ class Controller {
operator fun handleResult(value: String, y: Continuation<Nothing>) {
log += "return($value);"
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): String {
@@ -1,5 +1,6 @@
// WITH_RUNTIME
// TARGET_BACKEND: JVM
// NO_INTERCEPT_RESUME_TESTS
class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
@@ -16,6 +16,8 @@ class Controller {
suspend inline fun <reified T : Any> suspendInline(x: Continuation<String>) {
suspendInline({ T::class.simpleName!! }, x)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -27,6 +27,8 @@ class Controller {
postponedActions.removeAt(0)
}
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation<Unit>) {
@@ -3,6 +3,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resume((i++).toString())
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -11,6 +11,8 @@ class Controller {
val y: Any = x
x.resume(Continuation::class.isInstance(y as Continuation<*>))
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -4,6 +4,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -4,6 +4,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<Unit>) {
x.resume(Unit)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
+2
View File
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: String, c: Continuation<Nothing>) {
result = x
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): String {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(v: String, x: Continuation<String>) {
x.resume(v)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.(Long, String) -> Continuation<Unit>) {
@@ -9,6 +9,8 @@ class Controller {
operator fun handleResult(u: Unit, v: Continuation<Nothing>) {
ok = true
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): String {
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: Unit, y: Continuation<Nothing>) {
wasHandleResultCalled = true
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: Unit, y: Continuation<Nothing>) {
wasHandleResultCalled = true
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -9,6 +9,8 @@ class Controller {
operator fun handleResult(u: Unit, v: Continuation<Nothing>) {
ok = true
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): String {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -6,6 +6,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
// MODULE: main(controller)
@@ -11,6 +11,8 @@ class Controller {
inline suspend fun String.inlineSuspendHere(x: Continuation<String>) {
suspendHere(x)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
suspend fun Controller.suspendExtension(v: String, x: Continuation<String>) {
@@ -11,6 +11,8 @@ class Controller {
lastSuspension = null
x.resume("56")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -11,6 +11,8 @@ class Controller {
lastSuspension = null
x.resume("56")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -11,6 +11,8 @@ class Controller {
lastSuspension = null
x.resume("56")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -11,6 +11,8 @@ class Controller {
lastSuspension = null
x.resume("56")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -27,6 +27,8 @@ class Controller {
postponedActions.removeAt(0)
}
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation<Unit>) {
@@ -3,6 +3,8 @@ class Controller {
operator fun handleResult(x: Int, y: Continuation<Nothing>) {
res = x
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): Int {
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: Int, y: Continuation<Nothing>) {
cResult = x
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): Controller {
@@ -9,6 +9,8 @@ class Controller {
operator fun handleResult(x: Int, y: Continuation<Nothing>) {
cResult = x
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): Controller {
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: Int, y: Continuation<Nothing>) {
res = x
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): Int {
+2
View File
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resumeWithException(RuntimeException("OK"))
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: Int, y: Continuation<Nothing>) {
res = x
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>): Int {
@@ -7,6 +7,8 @@ class Controller {
operator fun handleResult(x: String, c: Continuation<Nothing>) {
globalResult = x
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -6,6 +6,8 @@ class Controller {
suspend fun suspendThere(x: Continuation<String>) {
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -7,6 +7,8 @@ class Controller {
inline suspend fun String.inlineSuspendHere(x: Continuation<String>) {
suspendHere(x)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
suspend fun Controller.suspendExtension(v: String, x: Continuation<String>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(v: Int, x: Continuation<Int>) {
x.resume(v * 2)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -6,6 +6,8 @@ class Controller {
suspend fun suspendThere(x: Continuation<String>) {
x.resume("?")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -10,6 +10,8 @@ class Controller {
suspend fun suspendWithDouble(v: Double, x: Continuation<Double>) {
x.resume(v)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -27,6 +27,8 @@ class Controller {
postponedActions.removeAt(0)
}
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation<Unit>) {
@@ -27,6 +27,8 @@ class Controller {
postponedActions.removeAt(0)
}
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(v: String, x: Continuation<String>) {
x.resume(v)
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -27,6 +27,8 @@ class Controller {
postponedActions.removeAt(0)
}
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(expectException: Boolean = false, coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
@@ -2,6 +2,8 @@ class Controller {
suspend fun suspendHere(x: Continuation<String>) {
x.resume("OK")
}
// INTERCEPT_RESUME_PLACEHOLDER
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {