mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
LibJS: Raise the upper minimum/maximum fraction digit limit to 100
This is a normative change in the ECMA-402 spec. See:
f6d2945
This commit is contained in:
parent
3fdf5072ec
commit
ea774111e8
3 changed files with 24 additions and 24 deletions
|
@ -324,11 +324,11 @@ ThrowCompletionOr<void> set_number_format_digit_options(VM& vm, NumberFormatBase
|
|||
if (need_fraction_digits) {
|
||||
// a. If hasFd is true, then
|
||||
if (has_fraction_digits) {
|
||||
// i. Set mnfd to ? DefaultNumberOption(mnfd, 0, 20, undefined).
|
||||
auto min_digits = TRY(default_number_option(vm, min_fraction_digits, 0, 20, {}));
|
||||
// i. Set mnfd to ? DefaultNumberOption(mnfd, 0, 100, undefined).
|
||||
auto min_digits = TRY(default_number_option(vm, min_fraction_digits, 0, 100, {}));
|
||||
|
||||
// ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 20, undefined).
|
||||
auto max_digits = TRY(default_number_option(vm, max_fraction_digits, 0, 20, {}));
|
||||
// ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined).
|
||||
auto max_digits = TRY(default_number_option(vm, max_fraction_digits, 0, 100, {}));
|
||||
|
||||
// iii. If mnfd is undefined, set mnfd to min(mnfdDefault, mxfd).
|
||||
if (!min_digits.has_value())
|
||||
|
|
|
@ -128,15 +128,15 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { minimumFractionDigits: "hello!" });
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { minimumFractionDigits: -1 });
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { minimumFractionDigits: 21 });
|
||||
}).toThrowWithMessage(RangeError, "Value 21 is NaN or is not between 0 and 20");
|
||||
new Intl.NumberFormat("en", { minimumFractionDigits: 101 });
|
||||
}).toThrowWithMessage(RangeError, "Value 101 is NaN or is not between 0 and 100");
|
||||
});
|
||||
|
||||
test("maximumFractionDigits option is invalid ", () => {
|
||||
|
@ -146,15 +146,15 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { maximumFractionDigits: "hello!" });
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { maximumFractionDigits: -1 });
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { maximumFractionDigits: 21 });
|
||||
}).toThrowWithMessage(RangeError, "Value 21 is NaN or is not between 0 and 20");
|
||||
new Intl.NumberFormat("en", { maximumFractionDigits: 101 });
|
||||
}).toThrowWithMessage(RangeError, "Value 101 is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { minimumFractionDigits: 10, maximumFractionDigits: 5 });
|
||||
|
@ -370,7 +370,7 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid minimumFractionDigits options", () => {
|
||||
for (let i = 0; i <= 20; ++i) {
|
||||
for (let i = 0; i <= 100; ++i) {
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { minimumFractionDigits: i });
|
||||
}).not.toThrow();
|
||||
|
@ -378,7 +378,7 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid maximumFractionDigits options", () => {
|
||||
for (let i = 0; i <= 20; ++i) {
|
||||
for (let i = 0; i <= 100; ++i) {
|
||||
expect(() => {
|
||||
new Intl.NumberFormat("en", { maximumFractionDigits: i });
|
||||
}).not.toThrow();
|
||||
|
|
|
@ -48,15 +48,15 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { minimumFractionDigits: "hello!" });
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { minimumFractionDigits: -1 });
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { minimumFractionDigits: 21 });
|
||||
}).toThrowWithMessage(RangeError, "Value 21 is NaN or is not between 0 and 20");
|
||||
new Intl.PluralRules("en", { minimumFractionDigits: 101 });
|
||||
}).toThrowWithMessage(RangeError, "Value 101 is NaN or is not between 0 and 100");
|
||||
});
|
||||
|
||||
test("maximumFractionDigits option is invalid ", () => {
|
||||
|
@ -66,15 +66,15 @@ describe("errors", () => {
|
|||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { maximumFractionDigits: "hello!" });
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value NaN is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { maximumFractionDigits: -1 });
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 20");
|
||||
}).toThrowWithMessage(RangeError, "Value -1 is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { maximumFractionDigits: 21 });
|
||||
}).toThrowWithMessage(RangeError, "Value 21 is NaN or is not between 0 and 20");
|
||||
new Intl.PluralRules("en", { maximumFractionDigits: 101 });
|
||||
}).toThrowWithMessage(RangeError, "Value 101 is NaN or is not between 0 and 100");
|
||||
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { minimumFractionDigits: 10, maximumFractionDigits: 5 });
|
||||
|
@ -208,7 +208,7 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid minimumFractionDigits options", () => {
|
||||
for (let i = 0; i <= 20; ++i) {
|
||||
for (let i = 0; i <= 100; ++i) {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { minimumFractionDigits: i });
|
||||
}).not.toThrow();
|
||||
|
@ -216,7 +216,7 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid maximumFractionDigits options", () => {
|
||||
for (let i = 0; i <= 20; ++i) {
|
||||
for (let i = 0; i <= 100; ++i) {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { maximumFractionDigits: i });
|
||||
}).not.toThrow();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue