Replace a couple of usages of suspendCoroutineOrReturn in tests
This commit is contained in:
+13
-6
@@ -8,17 +8,22 @@ import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
||||
x.resume("OK")
|
||||
COROUTINE_SUSPENDED
|
||||
var callback: () -> Unit = {}
|
||||
|
||||
suspend fun suspendHere(): String = suspendCoroutine { x ->
|
||||
callback = {
|
||||
x.resume("OK")
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun suspendWithException(): String = suspendCoroutineOrReturn { x ->
|
||||
x.resumeWithException(RuntimeException("OK"))
|
||||
COROUTINE_SUSPENDED
|
||||
suspend fun suspendWithException(): String = suspendCoroutine { x ->
|
||||
callback = {
|
||||
x.resumeWithException(RuntimeException("OK"))
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(shouldSuspend: Boolean, expectedCount: Int, c: suspend () -> String): String {
|
||||
callback = {}
|
||||
var fromSuspension: String? = null
|
||||
var counter = 0
|
||||
|
||||
@@ -39,6 +44,8 @@ fun builder(shouldSuspend: Boolean, expectedCount: Int, c: suspend () -> String)
|
||||
"Exception: ${e.message}"
|
||||
}
|
||||
|
||||
callback()
|
||||
|
||||
if (counter != expectedCount) throw RuntimeException("fail 0")
|
||||
|
||||
if (shouldSuspend) {
|
||||
|
||||
Reference in New Issue
Block a user