File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
kotlinx-coroutines-core/jvm/test/flow Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class TickerFlowTest : TestBase() {
20
20
}
21
21
22
22
@Test(expected = IllegalArgumentException ::class )
23
- fun testZeroNegativePeriod () = runTest {
23
+ fun testZeroPeriod () = runTest {
24
24
// WHEN
25
25
tickerFlow(0 ).launchIn(this )
26
26
}
@@ -50,6 +50,25 @@ class TickerFlowTest : TestBase() {
50
50
periodicTicker.cancelAndJoin()
51
51
}
52
52
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
+
53
72
54
73
@Test
55
74
fun testReceive () = runTest {
@@ -82,10 +101,10 @@ class TickerFlowTest : TestBase() {
82
101
}.launchIn(this )
83
102
84
103
delay(50 )
104
+ periodicTicker.cancel(CancellationException ())
85
105
86
106
// THEN
87
107
assertEquals(0 , inbox.size)
88
- periodicTicker.cancel(CancellationException ())
89
108
}
90
109
91
110
You can’t perform that action at this time.
0 commit comments