about summary refs log tree commit diff
path: root/library/core/tests/fmt
AgeCommit message (Collapse)AuthorLines
2025-01-26Put all coretests in a separate cratebjorn3-1541/+0
2025-01-24Fix `FormattingOptions` instantiation with `Default`Yuri Astrakhan-0/+6
The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`
2024-12-05Refactored FormattingOptions to use a bitmask for storing flagsElias Holzmann-10/+6
2024-12-05Added struct `fmt::FormattingOptions`Elias Holzmann-0/+28
This allows to build custom `std::Formatter`s at runtime. Also added some related enums and two related methods on `std::Formatter`.
2024-11-22Shorten the `MaybeUninit` `Debug` implementationTrevor Gross-0/+7
Currently the `Debug` implementation for `MaybeUninit` winds up being pretty verbose. This struct: #[derive(Debug)] pub struct Foo { pub a: u32, pub b: &'static str, pub c: MaybeUninit<u32>, pub d: MaybeUninit<String>, } Prints as: Foo { a: 0, b: "hello", c: core::mem::maybe_uninit::MaybeUninit<u32>, d: core::mem::maybe_uninit::MaybeUninit<alloc::string::String>, } The goal is just to be a standin for content so the path prefix doesn't add any useful information. Change the implementation to trim `MaybeUninit`'s leading path, meaning the new result is now: Foo { a: 0, b: "hello", c: MaybeUninit<u32>, d: MaybeUninit<alloc::string::String>, }
2024-07-21Implement `debug_more_non_exhaustive`Trevor Gross-2/+320
Add a `.finish_non_exhaustive()` method to `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`. This indicates that the structures have remaining items with `..`. This implements the ACP at <https://github.com/rust-lang/libs-team/issues/248>.
2024-07-21Make use of raw strings in `core::fmt::builders`Trevor Gross-37/+37
There are quite a few uses of escaped quotes. Turn these into raw strings within documentation and tests to make things easier to read.
2024-07-06Mark format! with must_use hintlukas-3/+3
2024-01-11apply fmtklensy-4/+4
2023-11-15avoid exhaustive i16 test in MiriRalf Jung-2/+5
2023-11-11round to evenJames Dietz-343/+10
2023-11-11fix rounding issue with exponents in fmtJames Dietz-4/+349
2023-03-16Update format_args!() test to account for inlining.Mara Bos-4/+4
2022-10-20Add tests for rounding of ties during float formattingAndrew Tribick-0/+120
2022-10-11Fix inconsistent rounding of 0.5 when formatted to 0 decimal placesAndrew Tribick-2/+2
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-68/+68
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2021-10-20Rollup merge of #86479 - exphp-forks:float-debug-exponential, r=yaahcYuki Okushi-0/+24
Automatic exponential formatting in Debug Context: See [this comment from the libs team](https://github.com/rust-lang/rfcs/pull/2729#issuecomment-853454204) --- Makes `"{:?}"` switch to exponential for floats based on magnitude. The libs team suggested exploring this idea in the discussion thread for RFC rust-lang/rfcs#2729. (**note:** this is **not** an implementation of the RFC; it is an implementation of one of the alternatives) Thresholds chosen were 1e-4 and 1e16. Justification described [here](https://github.com/rust-lang/rfcs/pull/2729#issuecomment-864482954). **This will require a crater run.** --- As mentioned in the commit message of 8731d4dfb47, this behavior will not apply when a precision is supplied, because I wanted to preserve the following existing and useful behavior of `{:.PREC?}` (which recursively applies `{:.PREC}` to floats in a struct): ```rust assert_eq!( format!("{:.2?}", [100.0, 0.000004]), "[100.00, 0.00]", ) ``` I looked around and am not sure where there are any tests that actually use this in the test suite, though? All things considered, I'm surprised that this change did not seem to break even a single existing test in `x.py test --stage 2`. (even when I tried a smaller threshold of 1e6)
2021-10-03Use a test value that doesn't depend on the handling of even/odd roundingJosh Triplett-1/+1
2021-10-03Fix Lower/UpperExp formatting for integers and precision zeroFabian Wolff-0/+1
2021-09-09Ignore automatically derived impls of `Clone` and `Debug` in dead code analysisFabian Wolff-0/+1
2021-06-19Automatic exponential formatting in DebugMichael Lamparski-0/+24
* {:.PREC?} already had legitimately useful behavior (recursive formatting of structs using fixed precision for floats) and I suspect that changes to the output there would be unwelcome. (besides, precision introduces sinister edge cases where a number can be rounded up to one of the thresholds) Thus, the new behavior of Debug is, "dynamically switch to exponential, but only if there's no precision." * This could not be implemented in terms of float_to_decimal_common without repeating the branch on precision, so 'float_to_general_debug' is a new function. The name is '_debug' instead of '_common' because the considerations in the previous bullet make this logic pretty specific to Debug. * 'float_to_decimal_common' is now only used by Display, so I inlined the min_precision argument and renamed the function accordingly.
2021-04-21Format `Struct { .. }` on one line even with `{:#?}`.Mara Bos-6/+1
2020-07-27mv std libs to library/mark-0/+1030