Skip to content

Commit

Permalink
~ Better checks in testRejectOnResumeInContext
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov committed Sep 14, 2020
1 parent f09fc9d commit fda826c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ class RejectedExecutionTest : TestBase() {
try {
withContext(Dispatchers.Default) {
expect(3)
assertDefaultDispatcherThread()
}
// cancelled on resume back
} finally {
expect(4)
assertIoThread()
}
expectUnreached()
}
}
assertEquals(2, executor.submittedTasks)
finish(4)
finish(5)
}

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

private fun assertDefaultDispatcherThread() {
val thread = Thread.currentThread()
if (thread !is CoroutineScheduler.Worker) error("Not a thread from Dispatchers.Default: $thread")
assertEquals(CoroutineScheduler.WorkerState.CPU_ACQUIRED, thread.state)
}

private fun assertIoThread() {
val thread = Thread.currentThread()
if (thread !is CoroutineScheduler.Worker) error("Not a thread from Dispatchers.IO: $thread")
Expand Down

0 comments on commit fda826c

Please sign in to comment.