@@ -4,6 +4,7 @@ import kotlinx.coroutines.channels.*
4
4
import org.junit.*
5
5
import reactor.blockhound.*
6
6
7
+ @Suppress(" UnusedEquals" , " DeferredResultUnused" , " BlockingMethodInNonBlockingContext" )
7
8
class BlockHoundTest : TestBase () {
8
9
9
10
@Before
@@ -12,21 +13,21 @@ class BlockHoundTest : TestBase() {
12
13
}
13
14
14
15
@Test(expected = BlockingOperationError ::class )
15
- fun shouldDetectBlockingInDefault () = runTest {
16
+ fun testShouldDetectBlockingInDefault () = runTest {
16
17
withContext(Dispatchers .Default ) {
17
18
Thread .sleep(1 )
18
19
}
19
20
}
20
21
21
22
@Test
22
- fun shouldNotDetectBlockingInIO () = runTest {
23
+ fun testShouldNotDetectBlockingInIO () = runTest {
23
24
withContext(Dispatchers .IO ) {
24
25
Thread .sleep(1 )
25
26
}
26
27
}
27
28
28
29
@Test
29
- fun shouldNotDetectNonblocking () = runTest {
30
+ fun testShouldNotDetectNonblocking () = runTest {
30
31
withContext(Dispatchers .Default ) {
31
32
val a = 1
32
33
val b = 2
@@ -54,7 +55,7 @@ class BlockHoundTest : TestBase() {
54
55
}
55
56
56
57
@Test
57
- fun testChannelsNotBeingConsideredBlocking () = runTest {
58
+ fun testChannelNotBeingConsideredBlocking () = runTest {
58
59
withContext(Dispatchers .Default ) {
59
60
// Copy of kotlinx.coroutines.channels.ArrayChannelTest.testSimple
60
61
val q = Channel <Int >(1 )
@@ -74,6 +75,24 @@ class BlockHoundTest : TestBase() {
74
75
}
75
76
}
76
77
78
+ @Test
79
+ fun testConflatedChannelsNotBeingConsideredBlocking () = runTest {
80
+ withContext(Dispatchers .Default ) {
81
+ val q = Channel <Int >(Channel .CONFLATED )
82
+ check(q.isEmpty)
83
+ check(! q.isClosedForReceive)
84
+ check(! q.isClosedForSend)
85
+ val sender = launch {
86
+ q.send(1 )
87
+ }
88
+ val receiver = launch {
89
+ q.receive() == 1
90
+ }
91
+ sender.join()
92
+ receiver.join()
93
+ }
94
+ }
95
+
77
96
@Test(expected = BlockingOperationError ::class )
78
97
fun testReusingThreadsFailure () = runTest {
79
98
val n = 100
0 commit comments