1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:47:36 +00:00

LibJS: Handle NumberFormat's [[UseGrouping]] option for "true" / "false"

This is a normative change to the Intl NumberFormat V3 spec. See:
4751da5
This commit is contained in:
Timothy Flynn 2022-09-13 11:00:58 -04:00 committed by Tim Flynn
parent 9743849ddb
commit 887dac0929
3 changed files with 24 additions and 7 deletions

View file

@ -209,6 +209,12 @@ describe("errors", () => {
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option signDisplay");
});
test("useGrouping option is invalid", () => {
expect(() => {
new Intl.NumberFormat("en", { useGrouping: "hello!" });
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option useGrouping");
});
test("roundingPriority option is invalid", () => {
expect(() => {
new Intl.NumberFormat("en", { roundingPriority: "hello!" });
@ -416,7 +422,7 @@ describe("normal behavior", () => {
});
test("valid useGrouping options", () => {
["min2", "auto", "always", false, true, ""].forEach(useGrouping => {
["min2", "auto", "always", false, true, "false", "true", ""].forEach(useGrouping => {
expect(() => {
new Intl.NumberFormat("en", { useGrouping: useGrouping });
}).not.toThrow();

View file

@ -287,9 +287,15 @@ describe("correct behavior", () => {
const en4 = new Intl.NumberFormat("en", { useGrouping: true });
expect(en4.resolvedOptions().useGrouping).toBe("always");
const en5 = new Intl.NumberFormat("en", { useGrouping: "false" });
expect(en5.resolvedOptions().useGrouping).toBe("auto");
const en6 = new Intl.NumberFormat("en", { useGrouping: "true" });
expect(en6.resolvedOptions().useGrouping).toBe("auto");
["auto", "always", "min2"].forEach(useGrouping => {
const en5 = new Intl.NumberFormat("en", { useGrouping: useGrouping });
expect(en5.resolvedOptions().useGrouping).toBe(useGrouping);
const en7 = new Intl.NumberFormat("en", { useGrouping: useGrouping });
expect(en7.resolvedOptions().useGrouping).toBe(useGrouping);
});
});