Skip to content

Commit

Permalink
Temporal: Additional tests for cases where date addition goes out of …
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed Oct 3, 2024
1 parent a9c026b commit b490361
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.hoursinday
description: >
Finding the boundary with the next day may throw if the instance is at the
upper edge of the representable range
features: [Temporal]
---*/

const instance = new Temporal.Duration();
const relativeTo = new Temporal.ZonedDateTime(86400_0000_0000_000_000_000n, "UTC");
assert.throws(
RangeError,
() => instance.round({ largestUnit: "days", smallestUnit: "minutes", relativeTo }),
"Next day boundary is out of range"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.hoursinday
description: >
Finding the boundary with the next day may throw if the instance is at the
upper edge of the representable range
features: [Temporal]
---*/

const z = new Temporal.ZonedDateTime(86400_0000_0000_000_000_000n, "UTC");
assert.throws(RangeError, () => z.hoursInDay, "Next day boundary is out of range");
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.prototype.round
description: >
Finding the upper bound for day rounding may fail if the instance is at the
upper edge of the representable range
features: [Temporal]
---*/

const instance = new Temporal.ZonedDateTime(86400_0000_0000_000_000_000n, "UTC");
assert.throws(RangeError, () => instance.round({ smallestUnit: 'day' }), "Upper bound for rounding is out of range");

0 comments on commit b490361

Please sign in to comment.