Skip to content

Commit fd8692e

Browse files
committed
~ Added failing test for Flow.combine that should be fixed
1 parent 5cd0c24 commit fd8692e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.coroutines.flow
@@ -238,6 +238,20 @@ abstract class CombineTestBase : TestBase() {
238238
assertFailsWith<CancellationException>(flow)
239239
finish(7)
240240
}
241+
242+
@Test
243+
fun testCancelledCombine() = runTest {
244+
coroutineScope {
245+
val flow = flow {
246+
emit(Unit) // emit to buffer
247+
cancel() // now cancel
248+
}
249+
flow.combineLatest(flow) { u, _ -> u }.collect {
250+
// should not be reached, because cancelled before it runs
251+
expectUnreached()
252+
}
253+
}
254+
}
241255
}
242256

243257
class CombineTest : CombineTestBase() {

0 commit comments

Comments
 (0)