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 test:Intl.NumberFormat using "currency" style and "compact", "engineering", or "scientific" notations. #4274

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2024 Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.numberformat
description: >
Checks that the special handling for number of fractional digits when formatting currency values in "standard" notation is ignored when using "compact", "engineering", or "scientific" notation.
info: |
Intl.DateTimeFormat ( [ locales [ , options ] ] )

...
19. If style is "currency" and "notation" is "standard", then
...
20. Else,
a. mnfdDefault be 0.
b. If style is "percent", then
i. Let mxfdDefault be 0.
c. Else,
i. Let mxfdDefault be 3.
---*/

for (const notation of ["compact", "engineering", "scientific"]) {
for (const currency of ["JPY", "KWD", "USD"]) {
let nf = new Intl.NumberFormat('en-US', {style: "currency", currency, notation});
const resolvedOptions = nf.resolvedOptions();
const minimumFractionDigits = resolvedOptions.minimumFractionDigits;
const maximumFractionDigits = resolvedOptions.maximumFractionDigits;

assert.sameValue(minimumFractionDigits, 0, "Didn't get correct minimumFractionDigits for " + currency + " in " + notation + " notation.");
assert.sameValue(maximumFractionDigits, 3, "Didn't get correct maximumFractionDigits for " + currency + " in " + notation + " notation.");
}
}


Loading