Skip to content

Commit fda826c

Browse files
committed
~ Better checks in testRejectOnResumeInContext
1 parent f09fc9d commit fda826c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt

+9-1
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ class RejectedExecutionTest : TestBase() {
6767
try {
6868
withContext(Dispatchers.Default) {
6969
expect(3)
70+
assertDefaultDispatcherThread()
7071
}
7172
// cancelled on resume back
7273
} finally {
74+
expect(4)
7375
assertIoThread()
7476
}
7577
expectUnreached()
7678
}
7779
}
7880
assertEquals(2, executor.submittedTasks)
79-
finish(4)
81+
finish(5)
8082
}
8183

8284
@Test
@@ -135,6 +137,12 @@ class RejectedExecutionTest : TestBase() {
135137
if (!thread.name.startsWith(threadName)) error("Not an executor thread: $thread")
136138
}
137139

140+
private fun assertDefaultDispatcherThread() {
141+
val thread = Thread.currentThread()
142+
if (thread !is CoroutineScheduler.Worker) error("Not a thread from Dispatchers.Default: $thread")
143+
assertEquals(CoroutineScheduler.WorkerState.CPU_ACQUIRED, thread.state)
144+
}
145+
138146
private fun assertIoThread() {
139147
val thread = Thread.currentThread()
140148
if (thread !is CoroutineScheduler.Worker) error("Not a thread from Dispatchers.IO: $thread")

0 commit comments

Comments
 (0)