mirror of
https://github.com/apple/swift-numerics
synced 2026-11-22 04:30:45 +00:00
Remove Int128 tests for now
Most people are not yet using a toolchain with support for Int128; we'll re-enable these when we bump the baseline to Swift 6.0
This commit is contained in:
2 files changed
-68
No files matched your search
@@ -467,44 +467,6 @@ final class IntegerUtilitiesDivideTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *)
|
||||
func divideUInt64(_ a: UInt64, _ b: UInt64, rounding rule: RoundingRule) {
|
||||
let expected = UInt64(Int128(a).divided(by: Int128(b), rounding: rule).quotient)
|
||||
let observed = a.divided(by: b, rounding: rule)
|
||||
guard expected == observed else {
|
||||
XCTFail("""
|
||||
\(a).divided(by: \(b), rounding: \(rule)) did not match expected result:
|
||||
Computed with Int128: \(expected)
|
||||
Computed with UInt64: \(observed)
|
||||
""")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *)
|
||||
func testDivideUInt64() {
|
||||
var values = [UInt64](repeating: 0, count: 64)
|
||||
for i in 0 ..< values.count {
|
||||
while values[i] == 0 {
|
||||
values[i] = .random(in: .min ... .max)
|
||||
}
|
||||
}
|
||||
for a in values {
|
||||
for b in values where b != 0 {
|
||||
divideUInt64(a, b, rounding: .down)
|
||||
divideUInt64(a, b, rounding: .up)
|
||||
divideUInt64(a, b, rounding: .towardZero)
|
||||
divideUInt64(a, b, rounding: .awayFromZero)
|
||||
divideUInt64(a, b, rounding: .toNearestOrDown)
|
||||
divideUInt64(a, b, rounding: .toNearestOrUp)
|
||||
divideUInt64(a, b, rounding: .toNearestOrZero)
|
||||
divideUInt64(a, b, rounding: .toNearestOrAway)
|
||||
divideUInt64(a, b, rounding: .toNearestOrEven)
|
||||
divideUInt64(a, b, rounding: .toOdd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stochastically rounding doesn't have a deterministic "expected" answer,
|
||||
// but we know that the result must be either the floor or the ceiling.
|
||||
// The above tests ensure that, but that's not a very strong guarantee;
|
||||
|
||||
@@ -167,32 +167,6 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
|
||||
testRoundingShift(UInt.self, rounding: .toNearestOrEven)
|
||||
testRoundingShift(UInt.self, rounding: .toOdd)
|
||||
testRoundingShift(UInt.self, rounding: .stochastically)
|
||||
|
||||
if #available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *) {
|
||||
testRoundingShift(Int128.self, rounding: .down)
|
||||
testRoundingShift(Int128.self, rounding: .up)
|
||||
testRoundingShift(Int128.self, rounding: .towardZero)
|
||||
testRoundingShift(Int128.self, rounding: .awayFromZero)
|
||||
testRoundingShift(Int128.self, rounding: .toNearestOrUp)
|
||||
testRoundingShift(Int128.self, rounding: .toNearestOrDown)
|
||||
testRoundingShift(Int128.self, rounding: .toNearestOrZero)
|
||||
testRoundingShift(Int128.self, rounding: .toNearestOrAway)
|
||||
testRoundingShift(Int128.self, rounding: .toNearestOrEven)
|
||||
testRoundingShift(Int128.self, rounding: .toOdd)
|
||||
testRoundingShift(Int128.self, rounding: .stochastically)
|
||||
|
||||
testRoundingShift(UInt128.self, rounding: .down)
|
||||
testRoundingShift(UInt128.self, rounding: .up)
|
||||
testRoundingShift(UInt128.self, rounding: .towardZero)
|
||||
testRoundingShift(UInt128.self, rounding: .awayFromZero)
|
||||
testRoundingShift(UInt128.self, rounding: .toNearestOrUp)
|
||||
testRoundingShift(UInt128.self, rounding: .toNearestOrDown)
|
||||
testRoundingShift(UInt128.self, rounding: .toNearestOrZero)
|
||||
testRoundingShift(UInt128.self, rounding: .toNearestOrAway)
|
||||
testRoundingShift(UInt128.self, rounding: .toNearestOrEven)
|
||||
testRoundingShift(UInt128.self, rounding: .toOdd)
|
||||
testRoundingShift(UInt128.self, rounding: .stochastically)
|
||||
}
|
||||
}
|
||||
|
||||
// Stochastic rounding doesn't have a deterministic "expected" answer,
|
||||
@@ -247,10 +221,6 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
|
||||
testStochasticAverage(UInt32.random(in: .min ... .max))
|
||||
testStochasticAverage(Int64.random(in: .min ... .max))
|
||||
testStochasticAverage(UInt64.random(in: .min ... .max))
|
||||
if #available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *) {
|
||||
testStochasticAverage(Int128.random(in: .min ... .max))
|
||||
testStochasticAverage(UInt128.random(in: .min ... .max))
|
||||
}
|
||||
testStochasticAverage(DoubleWidth<Int64>.random(in: .min ... .max))
|
||||
testStochasticAverage(DoubleWidth<UInt64>.random(in: .min ... .max))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user