Skip to content

Instantly share code, notes, and snippets.

@RBusarow
Last active July 13, 2019 23:39
Show Gist options
  • Save RBusarow/3dc233a3118b26cdd37e14eb2440719a to your computer and use it in GitHub Desktop.
Save RBusarow/3dc233a3118b26cdd37e14eb2440719a to your computer and use it in GitHub Desktop.
Example of dispatcher mutation
import io.kotlintest.*
@Test
fun `dispatcher mutation`() = runBlocking {
val testDispatcher = TestCoroutineDispatcher()
launch(testDispatcher) {
currentDispatcher() shouldBe testDispatcher
withContext(someOtherDispatcher) {
currentDispatcher() shouldBe someOtherDispatcher
}
}.join()
}
suspend fun currentDispatcher() = coroutineContext[ContinuationInterceptor]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment