Skip to content

Move several more float tests to floats/mod.rs #144923

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 10 commits into from
Aug 9, 2025

Conversation

rocurley
Copy link
Contributor

@rocurley rocurley commented Aug 4, 2025

This PR moves several tests to floats/mod.rs, as discussed in #141726. The tests moved are:

  • test_abs
  • test_signum
  • test_is_sign_positive
  • test_is_sign_negative
  • test_next_up
  • test_next_down
  • test_sqrt_domain
  • test_clamp_min_greater_than_max
  • test_clamp_min_is_nan
  • test_clamp_max_is_nan
  • test_total_cmp

This covers all the "easy" tests: the ones that don't have a lot of precision-specific constants. It's not clear to me that it's worth migrating the others.

Each test is its own commit (with the exception of the clamp tests), so it may be easiest to review each commit individually.

r? tgross35

@rustbot rustbot added 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. labels Aug 4, 2025
@rocurley rocurley marked this pull request as ready for review August 4, 2025 19:21
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 4, 2025
@rustbot

This comment has been minimized.

@rocurley rocurley force-pushed the float_tests_refactor_3 branch from 4737950 to 4e92c1c Compare August 4, 2025 19:24
@rust-log-analyzer

This comment has been minimized.

@rocurley rocurley marked this pull request as draft August 4, 2025 20:19
@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 Aug 4, 2025
@rocurley rocurley force-pushed the float_tests_refactor_3 branch from 4e92c1c to 4d3f410 Compare August 5, 2025 21:47
@rocurley rocurley marked this pull request as ready for review August 6, 2025 01:55
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 6, 2025
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.

This is great, thanks for getting these together! Just a few small comments.

Comment on lines 983 to 984
let one: Float = 1.0;
let zero: Float = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these are reused everywhere, maybe ONE and ZERO should be added to the trait?

Comment on lines 963 to 966
attrs: {
f16: #[cfg(false)],
f128: #[cfg(false)],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably just an oversight that f16/f128 didn't have these, I think it should work with the target_has..._math gates

rocurley added 10 commits August 7, 2025 22:03
This clobbers the existing generic abs test, but it covers strictly
more, so that seems fine.
Note that the behaviour of the f128 test is slightly changed to use the
same nan mask as is used in test_float_bits_conv, which is the behaviour
used by f16,f32,and f64.
This standardizes how max and min subnormals are generated. Since the
new method doesn't use powf, it also enables some of the tests for f128
that were previously disabled due to issues with powf (although it looks
like those issues were already fixed anyway). f16 signalling nan tests
previously disabled are not re-enabled, since the underlying LLVM issue
has not been closed.
@rocurley rocurley force-pushed the float_tests_refactor_3 branch from 4d3f410 to 57cf40c Compare August 8, 2025 02:52
@rocurley
Copy link
Contributor Author

rocurley commented Aug 8, 2025

@rustbot review

@tgross35
Copy link
Contributor

tgross35 commented Aug 8, 2025

Awesome, thank you!

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 8, 2025

📌 Commit 57cf40c has been approved by tgross35

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Aug 8, 2025

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 8, 2025
bors added a commit that referenced this pull request Aug 9, 2025
Rollup of 23 pull requests

Successful merges:

 - #141658 (rustdoc search: prefer stable items in search results)
 - #141828 (Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being used for stack buffer overruns if link.exe exits with that exit code)
 - #144823 (coverage: Extract HIR-related helper code out of the main module)
 - #144883 (Remove unneeded `drop_in_place` calls)
 - #144923 (Move several more float tests to floats/mod.rs)
 - #144988 (Add annotations to the graphviz region graph on region origins)
 - #145010 (Couple of minor abi handling cleanups)
 - #145017 (Explicitly disable vector feature on s390x baseline of bad-reg test)
 - #145027 (Optimize `char::is_alphanumeric`)
 - #145050 (add member constraints tests)
 - #145073 (update enzyme submodule to handle llvm 21)
 - #145080 (Escape diff strings in MIR dataflow graphviz)
 - #145082 (Fix some bad formatting in `-Zmacro-stats` output.)
 - #145083 (Fix cross-compilation of Cargo)
 - #145096 (Fix wasm target build with atomics feature)
 - #145097 (remove unnecessary `TypeFoldable` impls)
 - #145100 (Rank doc aliases lower than equivalently matched items)
 - #145103 (rustc_metadata: remove unused private trait impls)
 - #145115 (defer opaque type errors, generally greatly reduce tainting)
 - #145119 (rustc_public: fix missing parenthesis in pretty discriminant)
 - #145124 (Recover `for PAT = EXPR {}`)
 - #145132 (Refactor map_unit_fn lint)
 - #145134 (Reduce indirect assoc parent queries)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 9, 2025
Rollup of 23 pull requests

Successful merges:

 - #141658 (rustdoc search: prefer stable items in search results)
 - #141828 (Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being used for stack buffer overruns if link.exe exits with that exit code)
 - #144823 (coverage: Extract HIR-related helper code out of the main module)
 - #144883 (Remove unneeded `drop_in_place` calls)
 - #144923 (Move several more float tests to floats/mod.rs)
 - #144988 (Add annotations to the graphviz region graph on region origins)
 - #145010 (Couple of minor abi handling cleanups)
 - #145017 (Explicitly disable vector feature on s390x baseline of bad-reg test)
 - #145027 (Optimize `char::is_alphanumeric`)
 - #145050 (add member constraints tests)
 - #145073 (update enzyme submodule to handle llvm 21)
 - #145080 (Escape diff strings in MIR dataflow graphviz)
 - #145082 (Fix some bad formatting in `-Zmacro-stats` output.)
 - #145083 (Fix cross-compilation of Cargo)
 - #145096 (Fix wasm target build with atomics feature)
 - #145097 (remove unnecessary `TypeFoldable` impls)
 - #145100 (Rank doc aliases lower than equivalently matched items)
 - #145103 (rustc_metadata: remove unused private trait impls)
 - #145115 (defer opaque type errors, generally greatly reduce tainting)
 - #145119 (rustc_public: fix missing parenthesis in pretty discriminant)
 - #145124 (Recover `for PAT = EXPR {}`)
 - #145132 (Refactor map_unit_fn lint)
 - #145134 (Reduce indirect assoc parent queries)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7f77dfd into rust-lang:master Aug 9, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 9, 2025
rust-timer added a commit that referenced this pull request Aug 9, 2025
Rollup merge of #144923 - rocurley:float_tests_refactor_3, r=tgross35

Move several more float tests to floats/mod.rs

This PR moves several tests to `floats/mod.rs`, as discussed in #141726. The tests moved are:

* `test_abs`
* `test_signum`
* `test_is_sign_positive`
* `test_is_sign_negative`
* `test_next_up`
* `test_next_down`
* `test_sqrt_domain`
* `test_clamp_min_greater_than_max`
* `test_clamp_min_is_nan`
* `test_clamp_max_is_nan`
* `test_total_cmp`

This covers all the "easy" tests: the ones that don't have a lot of precision-specific constants. It's not clear to me that it's worth migrating the others.

Each test is its own commit (with the exception of the clamp tests), so it may be easiest to review each commit individually.

r? tgross35
@jieyouxu
Copy link
Member

jieyouxu commented Aug 9, 2025

Hi bors this already merged
@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 9, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Aug 9, 2025

@rustbot label: -S-waiting-on-author +S-waiting-on-bors +merged-by-bors

@rustbot rustbot added merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants