File tree 4 files changed +8
-4
lines changed
4 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public final class kotlinx/coroutines/test/TestCoroutineScheduler : kotlin/corou
69
69
public final fun advanceTimeBy-LRDsOJo (J)V
70
70
public final fun advanceUntilIdle ()V
71
71
public final fun getCurrentTime ()J
72
- public final fun getTimeSource ()Lkotlin/time/TimeSource;
72
+ public final fun getTimeSource ()Lkotlin/time/TimeSource$WithComparableMarks ;
73
73
public final fun runCurrent ()V
74
74
}
75
75
@@ -121,7 +121,7 @@ public final class kotlinx/coroutines/test/TestScopeKt {
121
121
public static final fun advanceTimeBy-HG0u8IE (Lkotlinx/coroutines/test/TestScope;J)V
122
122
public static final fun advanceUntilIdle (Lkotlinx/coroutines/test/TestScope;)V
123
123
public static final fun getCurrentTime (Lkotlinx/coroutines/test/TestScope;)J
124
- public static final fun getTestTimeSource (Lkotlinx/coroutines/test/TestScope;)Lkotlin/time/TimeSource;
124
+ public static final fun getTestTimeSource (Lkotlinx/coroutines/test/TestScope;)Lkotlin/time/TimeSource$WithComparableMarks ;
125
125
public static final fun runCurrent (Lkotlinx/coroutines/test/TestScope;)V
126
126
}
127
127
Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ public class TestCoroutineScheduler : AbstractCoroutineContextElement(TestCorout
224
224
* Returns the [TimeSource] representation of the virtual time of this scheduler.
225
225
*/
226
226
@ExperimentalTime
227
- public val timeSource: TimeSource = object : AbstractLongTimeSource (DurationUnit .MILLISECONDS ) {
227
+ public val timeSource: TimeSource . WithComparableMarks = object : AbstractLongTimeSource (DurationUnit .MILLISECONDS ) {
228
228
override fun read (): Long = currentTime
229
229
}
230
230
}
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ public fun TestScope.advanceTimeBy(delayTime: Duration): Unit = testScheduler.ad
136
136
*/
137
137
@ExperimentalCoroutinesApi
138
138
@ExperimentalTime
139
- public val TestScope .testTimeSource: TimeSource get() = testScheduler.timeSource
139
+ public val TestScope .testTimeSource: TimeSource . WithComparableMarks get() = testScheduler.timeSource
140
140
141
141
/* *
142
142
* Creates a [TestScope].
Original file line number Diff line number Diff line change @@ -315,10 +315,14 @@ class TestCoroutineSchedulerTest {
315
315
@ExperimentalTime
316
316
fun testAdvanceTimeSource () = runTest {
317
317
val expected = 1 .seconds
318
+ val before = testTimeSource.markNow()
318
319
val actual = testTimeSource.measureTime {
319
320
delay(expected)
320
321
}
321
322
assertEquals(expected, actual)
323
+ val after = testTimeSource.markNow()
324
+ assertTrue(before < after)
325
+ assertEquals(expected, after - before)
322
326
}
323
327
324
328
private fun forTestDispatchers (block : (TestDispatcher ) -> Unit ): Unit =
You can’t perform that action at this time.
0 commit comments