summary refs log tree commit diff
path: root/library/coretests
AgeCommit message (Collapse)AuthorLines
2025-06-20Rollup merge of #142668 - hkBst:less-static-mut, r=tgross35Trevor Gross-17/+13
vec_deque/fmt/vec tests: remove static mut More rust-lang/rust#125035. r? ```@tgross35```
2025-06-19atomic tests: remove static mutMarijn Schouten-17/+13
2025-06-18Add test for new format_args!() temporary lifetimes.Mara Bos-0/+15
2025-06-16Rollup merge of #142373 - m-ou-se:debug-for-location, r=tgross35Jakub Beránek-0/+8
Fix Debug for Location Fixes https://github.com/rust-lang/rust/issues/142279
2025-06-16Test Debug for Location.Mara Bos-0/+8
2025-06-14Rollup merge of #142243 - RalfJung:float-test-dedup, r=tgross35Matthias Krüger-676/+308
float tests: deduplicate min, max, and rounding tests Part of https://github.com/rust-lang/rust/issues/141726 Best reviewed commit-by-commit. - Use `assert_biteq!` in the `mod.rs` tests. This requires some trickery to make shadowing macros with imports work. - The min, max, minimum, maximum tests in `tests/floats/f*.rs` are entirely subsumed by what we already have in `tests/float/mod.rs`, so I just removed them. - The rounding tests (floor etc) in `f*.rs` had more test points, so I copied them over. They didn't have `0.5` and `-0.5` though which seem like interesting points in particular regarding the sign of the resulting zero if that's what it sounds to, and they didn't max min/max/inf/nan tests, so this was really a merger of both tests. r? ``@tgross35``
2025-06-14Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errorsMatthias Krüger-1/+0
Unimplement unsized_locals Implements https://github.com/rust-lang/compiler-team/issues/630 Tracking issue here: https://github.com/rust-lang/rust/issues/111942 Note that this just removes the feature, not the implementation, and does not touch `unsized_fn_params`. This is because it is required to support `Box<dyn FnOnce()>: FnOnce()`. There may be more that should be removed (possibly in follow up prs) - the `forget_unsized` function and `forget` intrinsic. - the `unsized_locals` test directory; I've just fixed up the tests for now - various codegen support for unsized values and allocas cc ``@JakobDegen`` ``@oli-obk`` ``@Noratrieb`` ``@programmerjake`` ``@bjorn3`` ``@rustbot`` label F-unsized_locals Fixes rust-lang/rust#79409
2025-06-13tweak runtime/const macro managementRalf Jung-44/+49
2025-06-13Unimplement unsized_localsmejrs-1/+0
2025-06-12Delegate `<CStr as Debug>` to `ByteStr`Tamir Duberstein-1/+1
This allows UTF-8 characters to be printed without escapes, rather than just ASCII.
2025-06-12Auto merge of #136594 - pascaldekloe:fmt-int128, r=tgross35bors-36/+121
Faster fmt::Display of 128-bit integers, without unsafe pointer In followup of #135265, hereby the 128-bit part. * Batches per 16 instead of 19 digits * Buffer access as array insteaf of unsafe pointer * Added test coverage for i128 and u128 r? tgross35 ChrisDenton
2025-06-11feat: Add `bit_width` for unsigned integer typesShun Sakai-0/+9
2025-06-10format integer tests regrouped, min/max coverage and 128-bit coveragePascal S. de Kloe-36/+121
2025-06-09Auto merge of #138062 - LorrensP-2158466:miri-enable-float-nondet, r=RalfJungbors-5/+12
Enable Non-determinism of float operations in Miri and change std tests Links to [#4208](https://github.com/rust-lang/miri/issues/4208) and [#3555](https://github.com/rust-lang/miri/issues/3555) in Miri. Non-determinism of floating point operations was disabled in rust-lang/rust#137594 because it breaks the tests and doc-tests in core/coretests and std. This PR enables some of them. This pr includes the following changes: - Enables the float non-determinism but with a lower relative error of 4ULP instead of 16ULP - These operations now have a fixed output based on the C23 standard, except the pow operations, this is tracked in [#4286](https://github.com/rust-lang/miri/issues/4286#issue-3010677983) - Changes tests that made incorrect assumptions about the operations, not to make that assumption anymore (from `assert_eq!` to `assert_approx_eq!`. - Changed the doctests of the stdlib of these operations to compare against fixed constants instead of `f*::EPSILON`, which now succeed with Miri and `-Zmiri-many-seeds` - Added a constant `APPROX_DELTA` in `std/tests/floats/f32.rs` which is used for approximation tests, but with a different value when run in Miri. This is to make these tests succeed. - Added tests in the float tests of Miri to test the C23 behaviour. Fixes https://github.com/rust-lang/miri/issues/4208
2025-06-09float midpoint tests: add missing NAN casesRalf Jung-0/+2
2025-06-09make the default float comparison tolerance type-dependentRalf Jung-15/+31
2025-06-09float tests: deduplicate min, max, and rounding testsRalf Jung-456/+56
2025-06-09float tests: use assert_biteq in more placesRalf Jung-215/+224
2025-06-07Make NonZero<char> possibleMarijn Schouten-5/+16
2025-06-07Rollup merge of #141857 - RalfJung:coretests-floats, r=tgross35Jacob Pratt-353/+548
coretests: move float tests from num to floats module and use a more flexible macro to generate them This makes some progress on https://github.com/rust-lang/rust/issues/141726 by moving the float tests in `num` to `floats` and using a newer, more flexible macro to generate them. We also newly run these tests on f16 and f128 in const, and at runtime in Miri and for hosts where that works well enough. I didn't yet deduplicate any tests or port the existing `floats::f*` tests to the macro, that can happen in a future PR. try-job: x86_64-gnu-aux
2025-06-05change tests to use fixed constants to let them pass with miriLorrensP-2158466-2/+7
2025-06-04coretests: move float tests from num to floats module and use a more ↵Ralf Jung-353/+548
flexible macro to generate them
2025-06-04Rollup merge of #141939 - Qelxiros:139911-exact-div-tests, r=workingjubileeMatthias Krüger-0/+62
exact_div: add tests tracking issue: rust-lang/rust#139911 I neglected to add tests in my last PR (rust-lang/rust#141237), so I've added them here. r? ``@workingjubilee`` (Feel free to reroll, I just picked you since you reviewed the last one.)
2025-06-03add tests for negative numbersJeremy Smart-0/+14
2025-06-03Enable Float non-determinism in miri. Update and add tests and changeLorrensP-2158466-3/+5
change tests in std, core and coretests.
2025-06-02add testsJeremy Smart-0/+48
2025-06-02Remove bootstrap cfgs from library/Josh Stone-6/+0
2025-05-31Add const support for float rounding methodsRuan Comelli-0/+115
Add const support for the float rounding methods floor, ceil, trunc, fract, round and round_ties_even. This works by moving the calculation logic from src/tools/miri/src/intrinsics/mod.rs into compiler/rustc_const_eval/src/interpret/intrinsics.rs. All relevant method definitions were adjusted to include the `const` keyword for all supported float types: f16, f32, f64 and f128. The constness is hidden behind the feature gate feature(const_float_round_methods) which is tracked in https://github.com/rust-lang/rust/issues/141555 This commit is a squash of the following commits: - test: add tests that we expect to pass when float rounding becomes const - feat: make float rounding methods `const` - fix: replace `rustc_allow_const_fn_unstable(core_intrinsics)` attribute with `#[rustc_const_unstable(feature = "f128", issue = "116909")]` in `library/core/src/num/f128.rs` - revert: undo update to `library/stdarch` - refactor: replace multiple `float_<mode>_intrinsic` rounding methods with a single, parametrized one - fix: add `#[cfg(not(bootstrap))]` to new const method tests - test: add extra sign tests to check `+0.0` and `-0.0` - revert: undo accidental changes to `round` docs - fix: gate `const` float round method behind `const_float_round_methods` - fix: remove unnecessary `#![feature(const_float_methods)]` - fix: remove unnecessary `#![feature(const_float_methods)]` [2] - revert: undo changes to `tests/ui/consts/const-eval/float_methods.rs` - fix: adjust after rebase - test: fix float tests - test: add tests for `fract` - chore: add commented-out `const_float_round_methods` feature gates to `f16` and `f128` - fix: adjust NaN when rounding floats - chore: add FIXME comment for de-duplicating float tests - test: remove unnecessary test file `tests/ui/consts/const-eval/float_methods.rs` - test: fix tests after upstream simplification of how float tests are run
2025-05-30Rollup merge of #141669 - tgross35:float-test-cleanup, r=RalfJungMatthias Krüger-717/+680
float: Replace some approximate assertions with exact As was mentioned at [1], we currently use `assert_approx_eq` for testing some math functions that guarantee exact results. Replace approximate assertions with exact ones for the following: * `ceil` * `floor` * `fract` * `from_bits` * `mul_add` * `round_ties_even` * `round` * `trunc` This likely wasn't done in the past to avoid writing out exact decimals that don't match the intuitive answer (e.g. 1.3 - 1.0 = 0.300...004), but ensuring our results are accurate seems more important here. [1]: https://github.com/rust-lang/rust/pull/138087#issuecomment-2842069281 The first commit is a small bit of macro cleanup. try-job: aarch64-gnu try-job: x86_64-gnu-aux
2025-05-29float: Use `assert_biteq!` where possibleTrevor Gross-482/+492
`assert_eq!` ignores the sign of zero, but for any tests involving zeros we do care about this sign. Replace `assert_eq!` with `assert_biteq!` everywhere possible for float tests to ensure we don't miss this. `assert_biteq!` is also updated to check equality on non-NaNs, to catch the unlikely case that bitwise equality works but our `==` implementation is broken. There is one notable output change: we were asserting that `(-0.0).fract()` and `(-1.0).fract()` both return -0.0, but both actually return +0.0.
2025-05-29float: Enable some f16 and f128 rounding tests on miriTrevor Gross-60/+26
The rounding tests are now supported, so there is no longer any reason to skip these.
2025-05-29float: Replace some approximate assertions with exactTrevor Gross-276/+276
As was mentioned at [1], we currently use `assert_approx_eq` for testing some math functions that guarantee exact results. Replace approximate assertions with exact ones for the following: * `ceil` * `floor` * `fract` * `from_bits` * `mul_add` * `round_ties_even` * `round` * `trunc` This likely wasn't done in the past to avoid writing out exact decimals that don't match the intuitive answer (e.g. 1.3 - 1.0 = 0.300...004), but ensuring our results are accurate seems more important here. [1]: https://github.com/rust-lang/rust/pull/138087#issuecomment-2842069281
2025-05-29float: Use a shared `assert_biteq!` macro for testsTrevor Gross-176/+163
Clean up the separate `assert_f{16,32,64,128}` macros with a single `assert_biteq!` macro that works for all float widths.
2025-05-29Rollup merge of #141676 - tgross35:f16-disable-total-cmp, r=workingjubileeGuillaume Gomez-37/+40
float: Disable `total_cmp` sNaN tests for `f16` There is an LLVM bug with lowering of basic `f16` operations that mean a round trip via `__extendhfsf2` and `__truncsfhf2` may happen for simple `abs` calls or bitcasts [1]. This is problematic because the round trip quiets signaling NaNs. For most operations this is acceptable, but it is causing `total_cmp` tests to fail unless optimizations are enabled. Disable `total_cmp` tests involving signaling NaNs until this issue is resolved. Fixes: https://github.com/rust-lang/rustc_codegen_cranelift/issues/1578 Fixes: https://github.com/rust-lang/rust/issues/141503 [1]: https://github.com/llvm/llvm-project/issues/104915
2025-05-29Rollup merge of #141571 - RalfJung:float-tests, r=tgross35Jacob Pratt-135/+114
coretests: extend and simplify float tests Also de-duplicate tests by removing a ui test that duplicates the tests in core. r? `@tgross35`
2025-05-28float: Disable `total_cmp` sNaN tests for `f16`Trevor Gross-37/+40
There is an LLVM bug with lowering of basic `f16` operations that mean a round trip via `__extendhfsf2` and `__truncsfhf2` may happen for simple `abs` calls or bitcasts [1]. This is problematic because the round trip quiets signaling NaNs. For most operations this is acceptable, but it is causing `total_cmp` tests to fail unless optimizations are enabled. Disable `total_cmp` tests involving signaling NaNs until this issue is resolved. Fixes: https://github.com/rust-lang/rustc_codegen_cranelift/issues/1578 Fixes: https://github.com/rust-lang/rust/issues/141503 [1]: https://github.com/llvm/llvm-project/issues/104915
2025-05-28coretests: add abs() and copysign() tests, and remove now-unnecessary ui testRalf Jung-45/+56
2025-05-28coretests: simplify test_float macro to derive more things from the type nameRalf Jung-134/+102
2025-05-24add CStr::displayTamir Duberstein-0/+7
The implementation delegates to `<ByteStr as Display>::fmt`. Link: https://github.com/rust-lang/libs-team/issues/550 Link: https://github.com/rust-lang/rust/issues/139984.
2025-05-22Auto merge of #137198 - tgross35:cfg-match-rename, r=Amanieubors-22/+22
Rename `cfg_match!` to `cfg_select!` [`@Nemo157` pointed out](https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605) that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this. Tracking issue: https://github.com/rust-lang/rust/issues/115585 [1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
2025-05-20Rename `cfg_match!` to `cfg_select!`Trevor Gross-22/+22
At [1] it was pointed out that `cfg_match!` syntax does not actually align well with match syntax, which is a possible source of confusion. The comment points out that usage is instead more similar to ecosystem `select!` macros. Rename `cfg_match!` to `cfg_select!` to match this. Tracking issue: https://github.com/rust-lang/rust/issues/115585 [1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
2025-05-20`core_float_math`: Move functions to `math` folderDaniel McNab-135/+136
When these functions were added in https://github.com/rust-lang/rust/pull/138087 It made a relatively common pattern for emulating these functions using an extension trait (which internally uses `libm`) much more fragile. If `core::f32` happened to be imported by the user (to access a constant, say), then that import in the module namespace would take precedence over `f32` in the type namespace for resolving these functions, running headfirst into the stability attribute. We ran into this in Color - https://github.com/linebender/color - and chose to release the remedial 0.3.1 and 0.2.4, to allow downstream crates to build on `docs.rs`. As these methods are perma-unstable, moving them into a new module should not have any long-term concerns, and ensures that this breakage doesn't adversely impact anyone else.
2025-05-18Auto merge of #127013 - tgross35:f16-format-parse, r=Mark-Simulacrumbors-77/+501
Add `f16` formatting and parsing Use the same algorithms as for `f32` and `f64` to implement `f16` parsing and printing. try-job: x86_64-gnu-aux
2025-05-18float: Add tests for `f16` conversions to and from decimalTrevor Gross-77/+501
Extend the existing tests for `f32` and `f64` with versions that include `f16`'s new printing and parsing implementations. Co-authored-by: Speedy_Lex <alex.ciocildau@gmail.com>
2025-05-18Rollup merge of #140924 - Urgau:f32_f64_const_tests, r=Mark-SimulacrumLeón Orell Valerian Liehr-143/+189
Make some `f32`/`f64` tests also run in const-context
2025-05-17Auto merge of #138087 - tgross35:core-float-math, r=Amanieubors-0/+2985
Initial implementation of `core_float_math` Since [1], `compiler-builtins` makes a certain set of math symbols weakly available on all platforms. This means we can begin exposing some of the related functions in `core`, so begin this process here. It is not possible to provide inherent methods in both `core` and `std` while giving them different stability gates, so standalone functions are added instead. This provides a way to experiment with the functionality while unstable; once it is time to stabilize, they can be converted to inherent. For `f16` and `f128`, everything is unstable so we can move the inherent methods. The following are included to start: * floor * ceil * round * round_ties_even * trunc * fract * mul_add * div_euclid * rem_euclid * powi * sqrt * abs_sub * cbrt These mirror the set of functions that we have in `compiler-builtins` since [1], with the exception of `powi` that has been there longer. Details for each of the changes is in the commit messages. Tracking issue: https://github.com/rust-lang/rust/issues/137578 [1]: https://github.com/rust-lang/compiler-builtins/pull/763 try-job: aarch64-gnu tru-job: armhf-gnu try-job: i686-msvc-1 try-job: test-various try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
2025-05-17Rollup merge of #140957 - JulianKnodt:array_must_use, r=Mark-SimulacrumMatthias Krüger-1/+1
Add `#[must_use]` to Array::map The output of Array::map is intended to be an array of the same size, and does not modify the original in place nor is it intended for side-effects. Thus, under normal circumstances it should be consumed. See [discussion](https://internals.rust-lang.org/t/array-map-annotate-with-must-use/22813/26). Attaching to tracking issue #75243
2025-05-14Skip {f32,f64}::mul_add tests on MinGWTrevor Gross-0/+4
Per [1], MinGW has an incorrect fma implementation. This showed up in tests run with cranelift after adding float math operations to `core`. Presumably we hadn't noticed this when running tests with LLVM because LLVM was constant folding the result away. Rust issue: https://github.com/rust-lang/rust/issues/140515 [1]: https://sourceforge.net/p/mingw-w64/bugs/848/
2025-05-14Move applicable float tests from `coretests` back to `std`Trevor Gross-1173/+148
The previous commit moved all test files from `std` to `core` so git understands the move. Not all functionality is actually testable in `core`, however, so perform move the relevant portions back. Changes from inherent to module methods is also done since this is the form of math operations available in `core` (as `core_float_math`).
2025-05-13Move float tests from std to coreTrevor Gross-0/+4006
Many float-related tests in `std` only depend on `core`, so move the tests there. This also allows us to verify functions from `core_float_math`. Since the majority of test files need to be moved to `coretests`, move the files here without any cleanup; this is done in a followup commit. This makes git history slightly cleaner, but coretests will not build immediately after this commit.