Minor. Use coroutine test helpers for inline/diagnostics tests

It should help with decreasing test data copy-pasting when
testing against release / pre-release coroutines
This commit is contained in:
Denis Zharkov
2018-06-26 15:10:58 +03:00
parent 2c195555ad
commit f01e690f49
49 changed files with 146 additions and 466 deletions
@@ -1,8 +1,10 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called from nested classes/lambdas (as common crossinlines)
// Are suspend calls possible inside lambda matching to the parameter
@@ -30,17 +32,7 @@ class Controller {
}
fun builder(controller: Controller, c: suspend Controller.() -> Unit) {
c.startCoroutine(controller, object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
})
c.startCoroutine(controller, EmptyContinuation)
}
// FILE: box.kt
@@ -1,8 +1,10 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called from nested classes/lambdas (as common crossinlines)
// Start coroutine call is possible
@@ -12,18 +14,6 @@ interface SuspendRunnable {
suspend fun run()
}
val EmptyContinuation = object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
}
class Controller {
var res = "FAIL 1"
@@ -1,8 +1,10 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called inside the body of owner inline function
// Block is allowed to be called from nested classes/lambdas (as common crossinlines)
@@ -34,23 +36,14 @@ class Controller {
}
fun builder(controller : Controller, c: suspend Controller.() -> Unit) {
c.startCoroutine(controller, object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
})
c.startCoroutine(controller, EmptyContinuation)
}
// FILE: box.kt
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import helpers.*
fun box() : String {
val controller = Controller()
@@ -1,8 +1,10 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called inside the body of owner inline function
// Block is allowed to be called from nested classes/lambdas (as common crossinlines)
@@ -38,19 +40,10 @@ class Controller {
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import helpers.*
fun builder(controller: Controller, c: suspend Controller.() -> Unit) {
c.startCoroutine(controller, object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
})
c.startCoroutine(controller, EmptyContinuation)
}
suspend fun calculate() = "OK"
@@ -1,8 +1,10 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called inside the body of owner inline function
// Block is allowed to be called from nested classes/lambdas (as common crossinlines)
@@ -34,23 +36,14 @@ class Controller {
}
fun builder(controller: Controller, c: suspend Controller.() -> Unit) {
c.startCoroutine(controller, object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
})
c.startCoroutine(controller, EmptyContinuation)
}
// FILE: box.kt
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import helpers.*
fun box() : String {
val controller = Controller()
@@ -1,8 +1,10 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called from nested classes/lambdas (as common crossinlines)
// Are suspend calls possible inside lambda matching to the parameter
@@ -13,17 +15,6 @@ interface SuspendRunnable {
suspend fun run()
}
object EmptyContinuation: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
}
class Controller {
var res = "FAIL 1"
@@ -59,6 +50,7 @@ fun builder(controller: Controller, c: suspend Controller.() -> Unit) {
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import helpers.*
suspend fun calculate() = "OK"
@@ -1,9 +1,11 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called inside the body of owner inline function
// suspend calls possible inside lambda matching to the parameter
@@ -21,23 +23,14 @@ class Controller {
}
fun builder(controller: Controller, c: suspend Controller.() -> Unit) {
c.startCoroutine(controller, object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
})
c.startCoroutine(controller, EmptyContinuation)
}
// FILE: box.kt
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import helpers.*
suspend fun calculate() = "OK"
@@ -1,9 +1,11 @@
// FILE: test.kt
// COMMON_COROUTINES_TEST
// WITH_RUNTIME
// WITH_COROUTINES
// NO_CHECK_LAMBDA_INLINING
import COROUTINES_PACKAGE.*
import helpers.*
// Block is allowed to be called inside the body of owner inline function
// suspend calls possible inside lambda matching to the parameter
@@ -20,19 +22,10 @@ class Controller {
// COMMON_COROUTINES_TEST
import COROUTINES_PACKAGE.*
import helpers.*
fun builder(controller: Controller, c: suspend Controller.() -> Unit) {
c.startCoroutine(controller, object: Continuation<Unit> {
override val context: CoroutineContext
get() = EmptyCoroutineContext
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
throw exception
}
})
c.startCoroutine(controller, EmptyContinuation)
}
suspend fun calculate() = "OK"