Skip to content

Commit c6cf814

Browse files
committed
add test for old behavior (dispatches when needed)
1 parent 32ffab8 commit c6cf814

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

kotlinx-coroutines-core/common/test/flow/channels/ChannelFlowTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,19 @@ class ChannelFlowTest : TestBase() {
222222
}
223223
expect(4)
224224
}
225+
226+
@Test
227+
fun testDispatchesToDifferentDispatcherWhenCollected() = runTest {
228+
expect(1)
229+
val myFlow = flow<Int> {
230+
finish(4)
231+
}.flowOn(wrapperDispatcher())
232+
launch(start = CoroutineStart.UNDISPATCHED) {
233+
expect(2)
234+
myFlow.collectLatest {
235+
expectUnreached()
236+
}
237+
}
238+
expect(3)
239+
}
225240
}

0 commit comments

Comments
 (0)