Skip to content

Commit a405c5d

Browse files
committed
test: repair stdlib/Dispatch on ASi
The conversion of the naonseconds to Mach ticks in multiples of Mach timebase units alters the time. This would fail on ASi where mach ticks are not synonymous with nanoseconds.
1 parent ceeceaa commit a405c5d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/stdlib/Dispatch.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,15 @@ DispatchAPI.test("DispatchTime.SchedulerTimeType.Stridable") {
278278
let time1 = DispatchQueue.SchedulerTimeType(.init(uptimeNanoseconds: 10000))
279279
let time2 = DispatchQueue.SchedulerTimeType(.init(uptimeNanoseconds: 10431))
280280
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)
282290
}
283291
}
284292

0 commit comments

Comments
 (0)