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:
parent
7acd174c85
commit
0e6d503317
2 changed files with 19 additions and 7 deletions
|
@ -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}`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue