-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Move NaN tests to floats/mod.rs #143396
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
base: master
Are you sure you want to change the base?
Move NaN tests to floats/mod.rs #143396
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -695,3 +695,24 @@ float_test! { | |
assert!(Float::NEG_INFINITY.fract().is_nan()); | ||
} | ||
} | ||
|
||
float_test! { | ||
name: nan, | ||
attrs: { | ||
f16: #[cfg(any(miri, target_has_reliable_f16_math))], | ||
f128: #[cfg(any(miri, target_has_reliable_f128_math))], | ||
}, | ||
test<Float> { | ||
use std::num::FpCategory as Fp; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you move it to the top of this file instead? The short form makes a bit more sense with the other infinite/finite/etc tests that also use it. (Not that we need to shorten it but 🤷♂ ) |
||
let nan: Float = Float::NAN; | ||
assert!(nan.is_nan()); | ||
assert!(!nan.is_infinite()); | ||
assert!(!nan.is_finite()); | ||
assert!(!nan.is_normal()); | ||
assert!(nan.is_sign_positive()); | ||
assert!(!nan.is_sign_negative()); | ||
assert!(matches!(nan.classify(), Fp::Nan)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is changed from an |
||
// Ensure the quiet bit is set. | ||
assert!(nan.to_bits() & (1 << (Float::MANTISSA_DIGITS - 2)) != 0); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, noticed something; could you use
target_has_reliable_f{16,128}
rather than the_math
versions?_math
is only for anything that callslibm
functions, which these don't.Mind also moving this above the other
float_test
instances? Might as well keep things ordered setup-> basic tests -> math tests, like the other test files.