diff --git a/src/commonTest/kotlin/app/cash/turbine/FlowInScopeTest.kt b/src/commonTest/kotlin/app/cash/turbine/FlowInScopeTest.kt index 41a1899a..d7d1778b 100644 --- a/src/commonTest/kotlin/app/cash/turbine/FlowInScopeTest.kt +++ b/src/commonTest/kotlin/app/cash/turbine/FlowInScopeTest.kt @@ -9,24 +9,16 @@ import kotlin.test.assertSame import kotlin.test.assertTrue import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.CompletionHandlerException -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.CoroutineStart +import kotlinx.coroutines.* import kotlinx.coroutines.Dispatchers.Default -import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.delay import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.onStart -import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest -import kotlinx.coroutines.withContext class FlowInScopeTest { @Test fun multipleFlows() = runTestTurbine { @@ -38,6 +30,27 @@ class FlowInScopeTest { turbine2.awaitComplete() } + @Test fun awaitFailsOnVirtualTime() = runTestTurbine { + assertFailsWith { + flow { + awaitCancellation() + }.test { + awaitComplete() + } + } + } + + @Test + fun awaitFailsOnDelayVirtualTime() = runTestTurbine { + assertFailsWith { + flow { + delay(1500.milliseconds) + }.test(timeout = 1000.milliseconds) { + awaitComplete() + } + } + } + @Test fun channelCancellation() = runTestTurbine { kotlin.runCatching {