Skip to content

Conversation

@JohnCari
Copy link

@JohnCari JohnCari commented Jan 15, 2026

Summary

This PR migrates duplicated float tests from library/std/tests/floats/ to use the unified float_test! macro infrastructure in library/coretests/tests/floats/mod.rs.

Tests migrated:

  • exp, exp2 - Exponential functions
  • ln, log, log2, log10 - Logarithmic functions
  • asinh, acosh, atanh - Inverse hyperbolic functions
  • gamma, ln_gamma - Gamma functions

Result:

  • +275 lines added to unified test infrastructure
  • -798 lines removed from duplicated type-specific tests
  • Net reduction of ~523 lines of duplicate code

All tests properly handle:

  • f16/f128 reliability via target_has_reliable_f16_math/target_has_reliable_f128_math
  • Miri compatibility via #[cfg(not(miri))]
  • Const evaluation opt-out via #[cfg(false)]

Fixes #141726

Test plan

  • ./x.py test library/coretests --stage 1 passes locally
  • ./x.py test library/std --stage 1 passes locally

Migrate the following tests from library/std/tests/floats/ to use the
unified float_test! macro infrastructure in library/coretests/tests/floats/mod.rs:

- exp, exp2: Exponential functions
- ln, log, log2, log10: Logarithmic functions
- asinh, acosh, atanh: Inverse hyperbolic functions
- gamma, ln_gamma: Gamma functions

This eliminates duplicate test code across f16, f32, f64, and f128 test files.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 15, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2026

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

The Cranelift codegen backend (cg_clif) does not support f16/f128 math
intrinsics, causing linker errors. Add `randomized_layouts` to check-cfg.
The Cranelift codegen backend (cg_clif) does not support f16/f128 math
intrinsics, which causes linker errors for undefined symbols like
logf16, expf16, etc.

Add `not(randomized_layouts)` to the cfg attributes for f16 and f128
math tests to skip them when running under Cranelift's randomized
layout testing, which sets the `randomized_layouts` cfg flag.
@rust-log-analyzer

This comment has been minimized.

After migrating exp, log, hyperbolic, and gamma function tests to the
unified float_test! macro infrastructure in library/coretests, the TOL
constant in library/std/tests/floats/f128.rs became unused.

This removes the dead code to fix the CI warning:
  "warning: constant `TOL` is never used"

The remaining constants (TOL_PRECISE, TOL_IMPR) are still used by
test_real_consts and test_powf respectively.
@JohnCari
Copy link
Author

@tgross35 @wycats let me know if you have any questions, im here to help!

@tgross35
Copy link
Contributor

Hello! Thank you for the interest, but I am afraid this conflicts with #148206

@JohnCari
Copy link
Author

Hello! Thank you for the interest, but I am afraid this conflicts with #148206

Hi @tgross35 can you reccomend me an issue to tackle?

@tgross35
Copy link
Contributor

Unfortunately I have no recommendations, but I think you were on the right track looking for E-Easy issues. Just keep your eyes peeled, or ask on Zulip if you are looking for something specific :)

@tgross35
Copy link
Contributor

Tests migrated:

* `exp`, `exp2` - Exponential functions
* `ln`, `log`, `log2`, `log10` - Logarithmic functions
* `asinh`, `acosh`, `atanh` - Inverse hyperbolic functions
* `gamma`, `ln_gamma` - Gamma functions

Result:

* **+275 lines** added to unified test infrastructure
* **-798 lines** removed from duplicated type-specific tests
* **Net reduction of ~523 lines** of duplicate code

All tests properly handle:

* f16/f128 reliability via `target_has_reliable_f16_math`/`target_has_reliable_f128_math`
* Miri compatibility via `#[cfg(not(miri))]`
* Const evaluation opt-out via `#[cfg(false)]`

For future reference, please do not include these AI-generated summaries. They're pure noise - we know what the functions do, GitHub shows you the +/- diffstat, and the third section is meaningless (the goal of review is to figure out if these things are done correctly. The statement happens to be wrong because I see some things that aren't).

@JohnCari
Copy link
Author

Unfortunately I have no recommendations, but I think you were on the right track looking for E-Easy issues. Just keep your eyes peeled, or ask on Zulip if you are looking for something specific :)

Ok then I will close this branch, thank you for the feedback

@JohnCari JohnCari closed this Jan 15, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 15, 2026
@JohnCari JohnCari deleted the unify-float-tests branch January 15, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Unify and deduplicate float tests

4 participants