Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rocurley
Copy link

@rocurley rocurley commented Jul 3, 2025

This PR moves NaN tests to floats/mod.rs, as discussed in #141726. Since this is my first PR against Rust, I'm keeping it as small as possible, but I intend to work my way through the remaining tests and can do that work in this PR if that's preferable.

r? RalfJung

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jul 3, 2025
f128: #[cfg(any(miri, target_has_reliable_f128_math))],
},
test<Float> {
use std::num::FpCategory as Fp;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The as Fp is copied from the original tests, but I don't actually see much reason for it.

Copy link
Contributor

Choose a reason for hiding this comment

The 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 🤷‍♂ )

assert!(!nan.is_normal());
assert!(nan.is_sign_positive());
assert!(!nan.is_sign_negative());
assert!(matches!(nan.classify(), Fp::Nan));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changed from an assert_eq to work in a const context.

@rocurley rocurley marked this pull request as ready for review July 3, 2025 19:36
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2025
@RalfJung
Copy link
Member

RalfJung commented Jul 3, 2025

I just opened that issue to track this, but for review I think it'd be better to
r? @tgross35

@rustbot rustbot assigned tgross35 and unassigned RalfJung Jul 3, 2025
Comment on lines +702 to +703
f16: #[cfg(any(miri, target_has_reliable_f16_math))],
f128: #[cfg(any(miri, target_has_reliable_f128_math))],
Copy link
Contributor

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 calls libm 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.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(just updating the status)

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants