Add Intl.NumberFormat tests for significant-digit rounding into the next magnitude - #5124
Open
jessealama wants to merge 4 commits into
Open
Add Intl.NumberFormat tests for significant-digit rounding into the next magnitude#5124jessealama wants to merge 4 commits into
jessealama wants to merge 4 commits into
Conversation
|
11 new or modified tests were run on 7 engines.
|
jessealama
force-pushed
the
numberformat-significant-digits-rollover
branch
from
September 2, 2026 15:33
8d538a0 to
3590a62
Compare
…cale The Collator test for ignored invalid extension values now builds its baseline collator from the base name as well, so that its resolved-locale and resolved-options comparisons use the same locale as the collators under test.
jessealama
force-pushed
the
numberformat-significant-digits-rollover
branch
from
September 6, 2026 21:02
3590a62 to
7565dbb
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #5126; the first two commits here are from that PR and will
drop out once it merges.
Add tests for
Intl.NumberFormatwhen rounding to a fixed number of significant digits carries into a new leading digit, e.g. 9.999 at three significant digits (should round to 10 rather than 9.99). As far as I can see, we don't have tests where the rounded value has a different order of magnitude from the input.I've added tests for a few locales & numbering systems outside of en-US/latn.
The
formattest covers different branches ofToRawPrecisionwhere we might conceivably place digits in different slots. We also test the interaction with trailing-zero trimming, and values just below the rounding boundary that must not roll over, given the significant digit settings in the formatter. TheformatToPartstest checks that grouping separators and decimal parts follow the rounded magnitude.This work arose in the process of working on the Amount proposal and its polyfill, where I noticed that some behavior I was relying on didn't seem to have test262 coverage. tc39/ecma402#572 is the spec fix whose behavior we're nailing down here.
Spec: https://tc39.es/ecma402/#sec-torawprecision