aboutsummaryrefslogtreecommitdiffstats
path: root/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-23 23:55:41 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-23 23:55:41 +0000
commitffe1b7dc19f3fbe1bc4a5f4f1e28c64cd68c5371 (patch)
tree747e5be83c6e6a2e2d9a164ebd03c5e45e6ec952 /reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
parent2bbecd60d31b5d0b48847f67e741018f5ae7aa07 (diff)
parent531d55eaeac09ad6cde55687ef802d4235040985 (diff)
downloadplatform_external_kotlinx.coroutines-simpleperf-release.tar.gz
platform_external_kotlinx.coroutines-simpleperf-release.tar.bz2
platform_external_kotlinx.coroutines-simpleperf-release.zip
Snap for 7668063 from 531d55eaeac09ad6cde55687ef802d4235040985 to simpleperf-releasesimpleperf-release
Change-Id: I844c9c61f2e31a265c36a483e1509e0e08c508d6
Diffstat (limited to 'reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt')
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt20
1 files changed, 19 insertions, 1 deletions
diff --git a/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt b/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
index 5bfddfee..5b3542ad 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
@@ -5,10 +5,12 @@
package kotlinx.coroutines.jdk9
import kotlinx.coroutines.*
+import kotlinx.coroutines.exceptions.*
import org.junit.Test
import kotlinx.coroutines.flow.flowOn
import org.junit.runner.*
import org.junit.runners.*
+import kotlin.contracts.*
import java.util.concurrent.Flow as JFlow
import kotlin.coroutines.*
import kotlin.test.*
@@ -129,4 +131,20 @@ class IntegrationTest(
assertEquals(n, last)
}
-} \ No newline at end of file
+}
+
+@OptIn(ExperimentalContracts::class)
+internal suspend inline fun <reified E: Throwable> assertCallsExceptionHandlerWith(
+ crossinline operation: suspend (CoroutineExceptionHandler) -> Unit): E {
+ contract {
+ callsInPlace(operation, InvocationKind.EXACTLY_ONCE)
+ }
+ val handler = CapturingHandler()
+ return withContext(handler) {
+ operation(handler)
+ handler.getException().let {
+ assertTrue(it is E, it.toString())
+ it
+ }
+ }
+}