@@ -37,7 +37,7 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
37
37
case . toNearestOrAwayFromZero:
38
38
if exact { expected = floor }
39
39
else {
40
- let step = value. shifted ( right : count - 2 , rounding: . toOdd)
40
+ let step = value. shifted ( rightBy : count - 2 , rounding: . toOdd)
41
41
switch step & 0b11 {
42
42
case 0b01 : expected = floor
43
43
case 0b10 : expected = value > 0 ? ceiling : floor
@@ -48,7 +48,7 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
48
48
case . toNearestOrEven:
49
49
if exact { expected = floor }
50
50
else {
51
- let step = value. shifted ( right : count - 2 , rounding: . toOdd)
51
+ let step = value. shifted ( rightBy : count - 2 , rounding: . toOdd)
52
52
switch step & 0b11 {
53
53
case 0b01 : expected = floor
54
54
case 0b10 : expected = floor & 1 == 0 ? floor : ceiling
@@ -61,9 +61,9 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
61
61
// or ceiling.
62
62
if exact { expected = floor }
63
63
else {
64
- let observed = value. shifted ( right : count, rounding: rule)
64
+ let observed = value. shifted ( rightBy : count, rounding: rule)
65
65
if observed != floor && observed != ceiling {
66
- print ( " Error found in \( T . self) .shifted(right : \( count) , rounding: \( rule) ). " )
66
+ print ( " Error found in \( T . self) .shifted(rightBy : \( count) , rounding: \( rule) ). " )
67
67
print ( " Value: \( String ( value, radix: 16 ) ) " )
68
68
print ( " Expected: \( String ( floor, radix: 16 ) ) or \( String ( ceiling, radix: 16 ) ) " )
69
69
print ( " Observed: \( String ( observed, radix: 16 ) ) " )
@@ -74,9 +74,9 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
74
74
case . requireExact:
75
75
preconditionFailure ( )
76
76
}
77
- let observed = value. shifted ( right : count, rounding: rule)
77
+ let observed = value. shifted ( rightBy : count, rounding: rule)
78
78
if observed != expected {
79
- print ( " Error found in \( T . self) .shifted(right : \( count) , rounding: \( rule) ). " )
79
+ print ( " Error found in \( T . self) .shifted(rightBy : \( count) , rounding: \( rule) ). " )
80
80
print ( " Value: \( String ( value, radix: 16 ) ) " )
81
81
print ( " Expected: \( String ( expected, radix: 16 ) ) " )
82
82
print ( " Observed: \( String ( observed, radix: 16 ) ) " )
@@ -89,7 +89,7 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
89
89
) {
90
90
for count in - 2 * T. bitWidth ... 2 * T. bitWidth {
91
91
// zero shifted by anything is always zero
92
- XCTAssertEqual ( 0 , ( 0 as T ) . shifted ( right : count, rounding: rule) )
92
+ XCTAssertEqual ( 0 , ( 0 as T ) . shifted ( rightBy : count, rounding: rule) )
93
93
for _ in 0 ..< 100 {
94
94
testRoundingShift ( T . random ( in: . min ... . max) , count, rounding: rule)
95
95
}
@@ -147,7 +147,7 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
147
147
var fails = 0
148
148
for count in 0 ... 64 {
149
149
let sum = ( 0 ..< 1024 ) . reduce ( into: 0.0 ) { sum, _ in
150
- let rounded = value. shifted ( right : count, rounding: . stochastically)
150
+ let rounded = value. shifted ( rightBy : count, rounding: . stochastically)
151
151
sum += Double ( rounded)
152
152
}
153
153
let expected = Double ( sign: . plus, exponent: - count, significand: 1024 * Double( value) )
@@ -164,15 +164,15 @@ final class IntegerUtilitiesShiftTests: XCTestCase {
164
164
// but if you see a repeated failure for a given shift count, that's
165
165
// almost surely a real bug.
166
166
XCTAssertLessThanOrEqual ( difference, 64 ,
167
- " Accumulated error ( \( difference) ) was unexpectedly large in \( value) .shifted(right : \( count) ) "
167
+ " Accumulated error ( \( difference) ) was unexpectedly large in \( value) .shifted(rightBy : \( count) ) "
168
168
)
169
169
}
170
170
// Threshold chosen so that this is expected to _almost always_ pass, but
171
171
// it may fail sporadically. This is not a great fit for CI workflows,
172
172
// sorry. Basically ignore one-off failures, but a repeated failure here
173
173
// is an indication that a bug exists.
174
174
XCTAssertLessThanOrEqual ( fails, 16 ,
175
- " Accumulated error was large more often than expected for \( value) .shifted(right :) "
175
+ " Accumulated error was large more often than expected for \( value) .shifted(rightBy :) "
176
176
)
177
177
}
178
178
0 commit comments