1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:37:35 +00:00

LibJS: Allow out-of-order plural ranges to be formatted

This is a normative change to the Intl NumberFormat V3 spec:
0c3d849
This commit is contained in:
Timothy Flynn 2022-07-26 07:12:46 -04:00 committed by Tim Flynn
parent fd7d97fba5
commit 417a385db1
3 changed files with 17 additions and 14 deletions

View file

@ -33,10 +33,6 @@ describe("errors", () => {
expect(() => {
new Intl.PluralRules().selectRange(1, NaN);
}).toThrowWithMessage(RangeError, "end must not be NaN");
expect(() => {
new Intl.PluralRules().selectRange(1, 0);
}).toThrowWithMessage(RangeError, "Range start 1 is greater than range end 0");
});
});
@ -70,4 +66,16 @@ describe("correct behavior", () => {
expect(so.selectRange(0, 1)).toBe("one");
expect(so.selectRange(1, 2)).toBe("other");
});
test("numbers in reverse order", () => {
const en = new Intl.PluralRules("en");
expect(en.selectRange(1, -Infinity)).toBe("other");
expect(en.selectRange(Infinity, -Infinity)).toBe("other");
expect(en.selectRange(-0, -Infinity)).toBe("other");
const ja = new Intl.PluralRules("ja");
expect(ja.selectRange(1, -Infinity)).toBe("other");
expect(ja.selectRange(Infinity, -Infinity)).toBe("other");
expect(ja.selectRange(-0, -Infinity)).toBe("other");
});
});