fix(intl): implement percent style for Intl.NumberFormat#5257
Closed
rubys wants to merge 1 commit intoboa-dev:mainfrom
Closed
fix(intl): implement percent style for Intl.NumberFormat#5257rubys wants to merge 1 commit intoboa-dev:mainfrom
rubys wants to merge 1 commit intoboa-dev:mainfrom
Conversation
Multiply the input value by 100 and append a percent sign when `style: "percent"` is used, matching the ECMA-402 spec. All three call sites (NumberFormat.format, Number.toLocaleString, BigInt.toLocaleString) now go through `format_to_js_string` so that style-specific affixes are applied consistently. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Test262 conformance changes
Fixed tests (1):Tested main commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5257 +/- ##
===========================================
+ Coverage 47.24% 59.87% +12.63%
===========================================
Files 476 589 +113
Lines 46892 63415 +16523
===========================================
+ Hits 22154 37970 +15816
- Misses 24738 25445 +707 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
As we've mentioned in other PRs, we prefer to wait for the required i18n APIs to be available from ICU4X instead of hacking around its limitations |
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.
Summary
Closes #5246.
multiply_pow10(2)) forstyle: "percent"per ECMA-402 FormatNumericformat_to_js_string()helperNumberFormat.format,Number.toLocaleString,BigInt.toLocaleString) to use the new helperKnown limitation
The percent sign is currently appended with a narrow no-break space (U+202F) uniformly across all locales. This is correct for most locales (e.g., French
"50 %", German"50 %"), but some locales (e.g., English) conventionally use no space ("50%"). The proper fix requires locale-aware percent formatting from ICU4X (see icu4x#4483). OncePercentFormatteris available upstream, this workaround should be replaced.Test262 conformance (
test/intl402/NumberFormat)Fixed tests (1):
test/prototype/format/percent-formatter.js(previously Failed)No regressions.
Test plan
cargo test -p boa_engine --features intl_bundled -- number_format— all 4 tests passcargo test -p boa_engine --features intl_bundled -- to_locale_string— existing tests unaffectedcargo clippy --all-features --all-targets— no warningscargo fmt -- --check— cleanboa_testeragainsttest/intl402/NumberFormat— +1 fixed, 0 broken🤖 Generated with Claude Code