Last active
July 13, 2019 23:39
-
-
Save RBusarow/3dc233a3118b26cdd37e14eb2440719a to your computer and use it in GitHub Desktop.
Example of dispatcher mutation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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