Skip to content

Commit 7e15913

Browse files
author
İbrahim Yilmaz
committed
testZeroNegativePeriod renamed to testZeroPeriod
testZeroInitialDelay added to test 0 initialDelay. testDoNotReceiveAfterCancel testcase fixed.
1 parent 70410db commit 7e15913

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

kotlinx-coroutines-core/jvm/test/flow/TickerFlowTest.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TickerFlowTest : TestBase() {
2020
}
2121

2222
@Test(expected = IllegalArgumentException::class)
23-
fun testZeroNegativePeriod() = runTest {
23+
fun testZeroPeriod() = runTest {
2424
// WHEN
2525
tickerFlow(0).launchIn(this)
2626
}
@@ -50,6 +50,25 @@ class TickerFlowTest : TestBase() {
5050
periodicTicker.cancelAndJoin()
5151
}
5252

53+
@Test
54+
fun testZeroInitialDelay() = runTest {
55+
// GIVEN
56+
val inbox = mutableListOf<Unit>()
57+
58+
// WHEN
59+
val periodicTicker =
60+
tickerFlow(100, 0).onEach {
61+
inbox.add(Unit)
62+
}.launchIn(this)
63+
64+
delay(500)
65+
66+
// THEN
67+
assertEquals(5, inbox.size)
68+
69+
periodicTicker.cancelAndJoin()
70+
}
71+
5372

5473
@Test
5574
fun testReceive() = runTest {
@@ -82,10 +101,10 @@ class TickerFlowTest : TestBase() {
82101
}.launchIn(this)
83102

84103
delay(50)
104+
periodicTicker.cancel(CancellationException())
85105

86106
// THEN
87107
assertEquals(0, inbox.size)
88-
periodicTicker.cancel(CancellationException())
89108
}
90109

91110

0 commit comments

Comments
 (0)