Skip to content

Commit 72140eb

Browse files
authored
Use run-time parsing to work around a compiler bug (#15923)
Due to SR-7124, some float literals are inconsistently handled across architectures. That's a problem for a test which is trying to verify that certain exact floating-point values are formatted in specific ways. Fortunately, the run-time float parsing does not have this problem, so I've changed this test to make sparing use of run-time parsing (`Float("1.234")`) instead of compile-time parsing (`1.234 as Float`). This is admittedly slower, but the test isn't particularly performance critical, and I don't want to use a hex literal here since I feel that would make the test case harder to understand.
1 parent 1380585 commit 72140eb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/stdlib/PrintFloat.swift.gyb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,10 @@ PrintTests.test("Printable_Float") {
570570
// closest to the midpoint between two binary floats
571571
expectDescription("7.0385313e-26", 7.0385313e-26 as Float)
572572
// Second-worst case for shortness:
573-
expectDescription("7.038531e-26", 7.038531e-26 as Float)
573+
expectDescription("7.038531e-26", Float("7.038531e-26")!)
574+
// Note: The above test computes the reference value from a
575+
// string because `7.038531e-26 as Float` is broken:
576+
// See https://bugs.swift.org/browse/SR-7124
574577

575578
// NaNs require special care in testing:
576579
// NaN is printed with additional detail to debugDescription, but not description

0 commit comments

Comments
 (0)