Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for "Intl NumberFormat v3" proposal #3301

Merged
merged 2 commits into from
Nov 30, 2021

Conversation

jugglinmike
Copy link
Contributor

This patch is intended to cover only one aspect of the proposal for
ECMA402: the "grouping enum" feature. It also includes coverage for the
formatting option as already defined by the latest version of ECMA402.


This is in service of gh-3132.

When adding test coverage for language proposals in "stage 3" of TC39's process, contributors to Test262 typically organize assertions within tests so that proposed semantics are encapsulated in dedicated files. This allows conforming engines to continue to benefit from coverage for standard behavior and to ignore the new behavior until they choose to opt in.

That is not always possible in this patch because the proposal includes semantics which contradict the current standard. I've included a note in the files where this was unavoidable so that it's easier for folks to update this when the proposal is standardized.

/cc @sffc

This patch is intended to cover only one aspect of the proposal for
ECMA402: the "grouping enum" feature. It also includes coverage for the
formatting option as already defined by the latest version of ECMA402.
@@ -0,0 +1,29 @@
// Copyright 2021 the V8 project authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: since you're including multiple locales, I think it would be useful to include "en-IN", which triggers the crore-style grouping separators. You probably don't need too many other locales for this feature.

@jugglinmike
Copy link
Contributor Author

Thanks, @sffc! I've removed the tests concerning ko-KR and zh-TW. I've also added tests for en-IN, but I'm not confident about their correctness. Specifically, I'm unsure about this case:

new Intl.NumberFormat('en-IN', {useGrouping: 'min2'}).format(100_000);

In your description from the original issue, you wrote "display grouping separators when there are at least 2 digits in a group." My interpretation of that statement is that the above invocation should produce "100,000", so that's how I've written the corresponding assertions in the latest commit.

However, the description of "min2" in the ICU seems somewhat vague about what happens for values greater than 10,000:

Display grouping using locale defaults, except do not show grouping on values smaller than 10000 (such that there is a minimum of two digits before the first separator).

Note that locales may restrict grouping separators to be displayed only on 1 million or greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).

Locale data is used to determine whether to separate larger numbers into groups of 2 (customary in South Asia) or groups of 3 (customary in Europe and the Americas).

I think that the answer may have to do with that last statement, "Locale data is used [...]", but I don't know how to interpret that.

@sffc
Copy link
Contributor

sffc commented Nov 16, 2021

Great question! I opened an issue to discuss: #77

@jugglinmike
Copy link
Contributor Author

Cool! GitHub interpreted that reference in terms of Test262. Here's the corresponding issue in the proposal's repository: tc39/proposal-intl-numberformat-v3#77

@rwaldron rwaldron merged commit ae9440d into main Nov 30, 2021
@rwaldron rwaldron deleted the bocoup/intl-numberformat-v3-grouping-enum branch November 30, 2021 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants