File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,15 @@ DispatchAPI.test("DispatchTime.SchedulerTimeType.Stridable") {
278
278
let time1 = DispatchQueue . SchedulerTimeType ( . init( uptimeNanoseconds: 10000 ) )
279
279
let time2 = DispatchQueue . SchedulerTimeType ( . init( uptimeNanoseconds: 10431 ) )
280
280
let addedTime = time2. distance ( to: time1)
281
- expectEqual ( ( 10000 - 10431 ) , addedTime. magnitude)
281
+ // The magnitude of the time sum is in nanosecond units. Although
282
+ // the units match up, the internal representation of the
283
+ // DispatchTime may round up to multiples of Mach timebase. This
284
+ // requires the difference being converted, which is performed here
285
+ // by constructing a `DispatchTime` from the delta. However, the
286
+ // parameter is a `UInt64` which requires us to perform the negation
287
+ // manually.
288
+ expectEqual ( - Int( DispatchTime ( uptimeNanoseconds: 10431 - 10000 ) . uptimeNanoseconds) ,
289
+ addedTime. magnitude)
282
290
}
283
291
}
284
292
You can’t perform that action at this time.
0 commit comments