aboutsummaryrefslogtreecommitdiffstats
path: root/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt')
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt36
1 files changed, 5 insertions, 31 deletions
diff --git a/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt b/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt
index d2ef3d26..ae05fb8d 100644
--- a/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.coroutines.channels
@@ -70,36 +70,10 @@ class ChannelUndeliveredElementFailureTest : TestBase() {
}
@Test
- fun testReceiveOrNullCancelledFail() = runTest(unhandled = shouldBeUnhandled) {
+ fun testReceiveCatchingCancelledFail() = runTest(unhandled = shouldBeUnhandled) {
val channel = Channel(onUndeliveredElement = onCancelFail)
val job = launch(start = CoroutineStart.UNDISPATCHED) {
- channel.receiveOrNull()
- expectUnreached() // will be cancelled before it dispatches
- }
- channel.send(item)
- job.cancel()
- }
-
- @Test
- fun testReceiveOrNullSelectCancelledFail() = runTest(unhandled = shouldBeUnhandled) {
- val channel = Channel(onUndeliveredElement = onCancelFail)
- val job = launch(start = CoroutineStart.UNDISPATCHED) {
- select<Unit> {
- channel.onReceiveOrNull {
- expectUnreached()
- }
- }
- expectUnreached() // will be cancelled before it dispatches
- }
- channel.send(item)
- job.cancel()
- }
-
- @Test
- fun testReceiveOrClosedCancelledFail() = runTest(unhandled = shouldBeUnhandled) {
- val channel = Channel(onUndeliveredElement = onCancelFail)
- val job = launch(start = CoroutineStart.UNDISPATCHED) {
- channel.receiveOrClosed()
+ channel.receiveCatching()
expectUnreached() // will be cancelled before it dispatches
}
channel.send(item)
@@ -111,7 +85,7 @@ class ChannelUndeliveredElementFailureTest : TestBase() {
val channel = Channel(onUndeliveredElement = onCancelFail)
val job = launch(start = CoroutineStart.UNDISPATCHED) {
select<Unit> {
- channel.onReceiveOrClosed {
+ channel.onReceiveCatching {
expectUnreached()
}
}
@@ -140,4 +114,4 @@ class ChannelUndeliveredElementFailureTest : TestBase() {
expectUnreached()
}
-} \ No newline at end of file
+}