forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#127510 - tgross35:test-float-parse-update, …
…r=Mark-Simulacrum Rewrite `test-float-parse` in Rust Migrate from the currently broken Rust + Python `test-float-parse` to a Rust implementation. This newer version should be significantly faster (tests execute in parallel with threads, rather than series across multiple processes, which also eliminates the "...the worker processes are leaked and stick around forever" message), and should be significantly easier to extend to the new float types. Since this is faster and hopefully more stable, we should be able to launch it with `x` and run the faster tests in CI.
- Loading branch information
Showing
36 changed files
with
2,509 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Float Parsing Tests | ||
|
||
These are tests designed to test decimal to float conversions (`dec2flt`) used | ||
by the standard library. | ||
|
||
It consistes of a collection of test generators that each generate a set of | ||
patterns intended to test a specific property. In addition, there are exhaustive | ||
tests (for <= `f32`) and fuzzers (for anything that can't be run exhaustively). | ||
|
||
The generators work as follows: | ||
|
||
- Each generator is a struct that lives somewhere in the `gen` module. Usually | ||
it is generic over a float type. | ||
- These generators must implement `Iterator`, which should return a context type | ||
that can be used to construct a test string (but usually not the string | ||
itself). | ||
- They must also implement the `Generator` trait, which provides a method to | ||
write test context to a string as a test case, as well as some extra metadata. | ||
|
||
The split between context generation and string construction is so that we can | ||
reuse string allocations. | ||
- Each generator gets registered once for each float type. Each of these | ||
generators then get their iterator called, and each test case checked against | ||
the float type's parse implementation. | ||
|
||
Some generators produce decimal strings, others create bit patterns that need to | ||
be bitcasted to the float type, which then uses its `Display` implementation to | ||
write to a string. For these, float to decimal (`flt2dec`) conversions also get | ||
tested, if unintentionally. | ||
|
||
For each test case, the following is done: | ||
|
||
- The test string is parsed to the float type using the standard library's | ||
implementation. | ||
- The test string is parsed separately to a `BigRational`, which acts as a | ||
representation with infinite precision. | ||
- The rational value then gets checked that it is within the float's | ||
representable values (absolute value greater than the smallest number to round | ||
to zero, but less less than the first value to round to infinity). If these | ||
limits are exceeded, check that the parsed float reflects that. | ||
- For real nonzero numbers, the parsed float is converted into a rational using | ||
`significand * 2^exponent`. It is then checked against the actual rational | ||
value, and verified to be within half a bit's precision of the parsed value. | ||
Also it is checked that ties round to even. | ||
|
||
This is all highly parallelized with `rayon`; test generators can run in | ||
parallel, and their tests get chunked and run in parallel. | ||
|
||
There is a simple command line that allows filtering which tests are run, | ||
setting the number of iterations for fuzzing tests, limiting failures, setting | ||
timeouts, etc. See `main.rs` or run with `--help` for options. | ||
|
||
Note that when running via `./x`, only tests that take less than a few minutes | ||
are run by default. Navigate to the crate (or pass `-C` to Cargo) and run it | ||
directly to run all tests or pass specific arguments. |
Oops, something went wrong.