Skip to content

Commit 5782dd4

Browse files
authored
Merge pull request #33343 from compnerd/dispatch-ASi
test: repair stdlib/Dispatch on ASi
2 parents 63da97d + a405c5d commit 5782dd4

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)