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

LibJS: Throw RangeError for non-integral values in ToPartialDuration

This is a normative change in the Temporal spec.

See: 895c8e5
This commit is contained in:
Linus Groh 2021-09-02 18:58:50 +01:00
parent 7acd174c85
commit 0e6d503317
2 changed files with 19 additions and 7 deletions

View file

@ -79,9 +79,14 @@ describe("errors", () => {
test("invalid duration value", () => {
for (const property of DURATION_PROPERTIES) {
expect(() => {
new Temporal.Duration().with({ [property]: Infinity });
}).toThrowWithMessage(RangeError, "Invalid duration");
for (const value of [1.23, NaN, Infinity]) {
expect(() => {
new Temporal.Duration().with({ [property]: value });
}).toThrowWithMessage(
RangeError,
`Invalid value for duration property '${property}': must be an integer, got ${value}`
);
}
}
});
});