mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 06:40:05 +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
Notes:
sideshowbarker
2024-07-18 04:52:36 +09:00
Author: https://github.com/linusg
Commit: 0e6d503317
Pull-request: https://github.com/SerenityOS/serenity/pull/9752
Reviewed-by: https://github.com/IdanHo ✅
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