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

LibJS: Throw a RangeError when when formatting strings in DurationFormat

This is a normative change in the Intl.DurationFormat proposal. See:
2546080
This commit is contained in:
Timothy Flynn 2022-12-14 15:30:34 -05:00 committed by Linus Groh
parent 010888acec
commit a2cf026b30
3 changed files with 19 additions and 4 deletions

View file

@ -92,7 +92,11 @@ describe("correct behavior", () => {
describe("errors", () => {
test("non-object duration records", () => {
[-100, Infinity, NaN, "hello", 152n, Symbol("foo")].forEach(value => {
expect(() => {
new Intl.DurationFormat().format("hello");
}).toThrowWithMessage(RangeError, "is not an object");
[-100, Infinity, NaN, 152n, Symbol("foo"), true, null, undefined].forEach(value => {
expect(() => {
new Intl.DurationFormat().format(value);
}).toThrowWithMessage(TypeError, "is not an object");

View file

@ -266,7 +266,11 @@ describe("correct behavior", () => {
describe("errors", () => {
test("non-object duration records", () => {
[-100, Infinity, NaN, "hello", 152n, Symbol("foo")].forEach(value => {
expect(() => {
new Intl.DurationFormat().formatToParts("hello");
}).toThrowWithMessage(RangeError, "is not an object");
[-100, Infinity, NaN, 152n, Symbol("foo"), true, null, undefined].forEach(value => {
expect(() => {
new Intl.DurationFormat().formatToParts(value);
}).toThrowWithMessage(TypeError, "is not an object");