about summary refs log tree commit diff
path: root/library/coretests/tests/num
AgeCommit message (Collapse)AuthorLines
2025-09-18Rollup merge of #146487 - ferrocene:pvdrz/improve-num-coverage, r=joboetMatthias Krüger-0/+7
Improve `core::num` coverage This PR improves the `core::num` coverage by adding a new test to `coretests`. r? libs
2025-09-12Improve `core::num` coverageChristian Poveda-0/+7
2025-09-07remove unsused div_rem method from bignumKivooeo-19/+0
2025-09-03Add `funnel_sh{l,r}` functions and intrinsicssayantn-0/+36
- Add a fallback implementation for the intrinsics - Add LLVM backend support for funnel shifts Co-Authored-By: folkertdev <folkert@folkertdev.nl>
2025-08-18Implement feature `int_lowest_highest_one` for integer and NonZero typesAlexandre Courbot-0/+74
Implement the accepted ACP for methods that find the index of the least significant (lowest) and most significant (highest) set bit in an integer for signed, unsigned, and NonZero types. Also add unit tests for all these types.
2025-08-08Clean up some resolved test regressions of const trait removals in stdShoyu Vanilla-2/+0
2025-08-05Renamed `isolate_most_least_significant_one` functionsokaneco-12/+12
libs-api has agreed to rename these functions to `isolate_highest_one`/`isolate_lowest_one`
2025-07-23coretests/num: use ldexp instead of hard-coding a power of 2Ralf Jung-32/+38
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-06-11feat: Add `bit_width` for unsigned integer typesShun Sakai-0/+8
2025-06-09Auto merge of #138062 - LorrensP-2158466:miri-enable-float-nondet, r=RalfJungbors-2/+4
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-07Make NonZero<char> possibleMarijn Schouten-5/+16
2025-06-07Rollup merge of #141857 - RalfJung:coretests-floats, r=tgross35Jacob Pratt-353/+0
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-04coretests: move float tests from num to floats module and use a more ↵Ralf Jung-353/+0
flexible macro to generate them
2025-06-04Rollup merge of #141939 - Qelxiros:139911-exact-div-tests, r=workingjubileeMatthias Krüger-0/+61
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-2/+4
change tests in std, core and coretests.
2025-06-02add testsJeremy Smart-0/+47
2025-06-02Remove bootstrap cfgs from library/Josh Stone-6/+0
2025-05-31Add const support for float rounding methodsRuan Comelli-0/+114
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-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-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-11Make some `f32`/`f64` tests also run in const-contextUrgau-143/+189
2025-03-21coretests stop relying on `inline_const_pat`lcnr-596/+604
2025-03-10Update tests.Mara Bos-14/+14
2025-03-10Limit formatting width and precision to 16 bits.Mara Bos-1/+1
2025-03-02dec2flt: Refactor float traitsTrevor Gross-0/+61
A lot of the magic constants can be turned into expressions. This reduces some code duplication. Additionally, add traits to make these operations fully generic. This will make it easier to support `f16` and `f128`.
2025-03-02dec2flt: Rename fields to be consistent with documented notationTrevor Gross-6/+6
2025-03-02dec2flt: Rename `Number` to `Decimal`Trevor Gross-13/+42
The previous commit renamed `Decimal` to `DecimalSeq`. Now, rename the type that represents a decimal floating point number to be `Decimal`. Additionally, add some tests for internal behavior.
2025-03-02dec2flt: Rename `Decimal` to `DecimalSeq`Trevor Gross-0/+31
This module currently contains two decimal types, `Decimal` and `Number`. These names don't provide a whole lot of insight into what exactly they are, and `Number` is actually the one that is more like an expected `Decimal` type. In accordance with this, rename the existing `Decimal` to `DecimalSeq`. This highlights that it contains a sequence of decimal digits, rather than representing a base-10 floating point (decimal) number. Additionally, add some tests to validate internal behavior.
2025-02-27checked_ilog tests: deal with a bit of float imprecisionRalf Jung-18/+56
2025-02-25disable a potentially bogus test on MiriRalf Jung-0/+1
2025-02-24Rollup merge of #137393 - chorman0773:unbounded-shifts-stabilize, r=AmanieuJacob Pratt-0/+328
Stabilize `unbounded_shifts` This stabilizes and const-stabilizes `<iN>::unbounded_shl` and `<uN>::unbounded_shr` from https://github.com/rust-lang/rust/issues/129375.
2025-02-22Rollup merge of #136910 - okaneco:sig_ones, r=thomccMatthias Krüger-0/+68
Implement feature `isolate_most_least_significant_one` for integer types Accepted ACP - https://github.com/rust-lang/libs-team/issues/467 Tracking issue - #136909 Implement ACP for functions that isolate the most significant set bit and least significant set bit on unsigned, signed, and `NonZero` integers. Add function `isolate_most_significant_one` Add function `isolate_least_significant_one` --- This PR adds the following impls ```rust impl {u8, u16, u32, u64, u128, usize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl {i8, i16, i32, i64, i128, isize} { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } impl NonZeroT { const fn isolate_most_significant_one(self) -> Self; const fn isolate_least_significant_one(self) -> Self; } ``` Example behavior ```rust assert_eq!(u8::isolate_most_significant_one(0b01100100), 0b01000000); assert_eq!(u8::isolate_least_significant_one(0b01100100), 0b00000100); ```
2025-02-21Fix unbounded_shifts testsConnor Horman-13/+22
2025-02-21Stabilize `unbounded_shifts`Connor Horman-0/+319
2025-02-20Implement feature `isolate_most_least_significant_one` for integer typesokaneco-0/+68
Implement accepted ACP for functions that isolate the most significant set bit and least significant set bit on unsigned, signed, and NonZero integers. Add function `isolate_most_significant_one` Add function `isolate_least_significant_one` Add tests
2025-02-13library: Update rand to 0.9.0Eric Huss-3/+3
2025-02-09Mark extern blocks as unsafeMichael Goulet-1/+1
2025-01-26Put all coretests in a separate cratebjorn3-0/+5283