mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 02:09:24 +00:00
LibJS: Use currency digits for NumberFormat only for standard notation
This is a normative change in the ECMA-402 spec. See:
9140da2
This commit is contained in:
parent
96c059bf67
commit
37b8ba96f1
Notes:
github-actions[bot]
2025-03-18 15:48:29 +00:00
Author: https://github.com/trflynn89
Commit: 37b8ba96f1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3980
2 changed files with 32 additions and 12 deletions
|
@ -95,6 +95,26 @@ describe("correct behavior", () => {
|
|||
expect(en2.resolvedOptions().maximumFractionDigits).toBe(2);
|
||||
});
|
||||
|
||||
test("currency digits are not used for non-standard notation", () => {
|
||||
const en1 = new Intl.NumberFormat("en", {
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
notation: "engineering",
|
||||
});
|
||||
expect(en1.resolvedOptions().style).toBe("currency");
|
||||
expect(en1.resolvedOptions().minimumFractionDigits).toBe(0);
|
||||
expect(en1.resolvedOptions().maximumFractionDigits).toBe(3);
|
||||
|
||||
const en2 = new Intl.NumberFormat("en", {
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
notation: "compact",
|
||||
});
|
||||
expect(en2.resolvedOptions().style).toBe("currency");
|
||||
expect(en2.resolvedOptions().minimumFractionDigits).toBe(0);
|
||||
expect(en2.resolvedOptions().maximumFractionDigits).toBe(0);
|
||||
});
|
||||
|
||||
test("other style options default to min fraction digits of 0 and max fraction digits of 0 or 3", () => {
|
||||
const en1 = new Intl.NumberFormat("en", { style: "decimal" });
|
||||
expect(en1.resolvedOptions().style).toBe("decimal");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue