blob: a066f6b3a92e9f3f85c411354475fa69d769df5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/*
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.coroutines.selects
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
class SelectLinkedListChannelTest : TestBase() {
@Test
fun testSelectSendWhenClosed() = runTest {
expect(1)
val c = Channel<Int>(Channel.UNLIMITED)
c.send(1) // enqueue buffered element
c.close() // then close
assertFailsWith<ClosedSendChannelException> {
// select sender should fail
expect(2)
select {
c.onSend(2) {
expectUnreached()
}
}
}
finish(3)
}
}
|