Skip to content

Don't verify exact NaN text for .debugDescription #33391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions test/stdlib/PrintFloat.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -442,21 +442,20 @@ fileprivate func expectNaN<T>(_ expected: String, _ object: T,
message(),
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line))

// debugDescription prints full details about NaNs, which is tricky to test
// because NaNs often get truncated: various implementations force all NaNs
// quiet, discard payloads, or clear sign bits. In some cases, just passing a
// NaN into a function (via an FP register) is enough to mangle the value.

#if arch(x86_64)
// Verify the exact debugDescription value only on x86_64, where we
// know the exact expected String:
// debugDescription tries to print details about NaNs, which is tricky to test.

/*
// We cannot reliably test the exact expected string, because various
// implementations force all NaNs quiet, discard payloads, or clear sign bits.
// In some cases, just passing a NaN into a function (via an FP register) is
// enough to mangle the value.
expectEqual(expected, object.debugDescription,
message(),
stackTrace: stackTrace.pushIf(showFrame, file: file, line: line))
#endif
*/

// On all platforms, we verify that the generated debugDescription text
// follows the expected format, even when we can't verify the exact value.
// We can verify that the generated debugDescription text
// follows the expected general format, even when we can't verify the exact value.
var actual = object.debugDescription

// Optional leading "-"
Expand Down