-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for adding negative durations to/subtracting durations from…
… the last representable year/month of the ISO calendar See tc39/proposal-temporal#3029
- Loading branch information
1 parent
45f352d
commit 4ae5a1d
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...built-ins/Temporal/PlainYearMonth/prototype/add/subtract-from-last-representable-month.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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.plainyearmonth.prototype.add | ||
description: RangeError thrown when adding negative duration to last representable month. | ||
features: [Temporal] | ||
---*/ | ||
|
||
const lastMonth = new Temporal.PlainYearMonth(275760, 9); | ||
|
||
// See https://tc39.es/proposal-temporal/#sec-temporal-adddurationtoyearmonth | ||
// (step 10d) | ||
assert.throws(RangeError, () => lastMonth.add({seconds: -1})); | ||
assert.throws(RangeError, () => lastMonth.add({minutes: -1})); | ||
assert.throws(RangeError, () => lastMonth.add({hours: -1})); | ||
assert.throws(RangeError, () => lastMonth.add({days: -1})); | ||
assert.throws(RangeError, () => lastMonth.add({weeks: -1})); | ||
assert.throws(RangeError, () => lastMonth.add({months: -1})); | ||
assert.throws(RangeError, () => lastMonth.add({years: -1})); | ||
|
21 changes: 21 additions & 0 deletions
21
...-ins/Temporal/PlainYearMonth/prototype/subtract/subtract-from-last-representable-month.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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.plainyearmonth.prototype.subtract | ||
description: RangeError thrown when subtracting duration from last representable month. | ||
features: [Temporal] | ||
---*/ | ||
|
||
const lastMonth = new Temporal.PlainYearMonth(275760, 9); | ||
|
||
// See https://tc39.es/proposal-temporal/#sec-temporal-adddurationtoyearmonth | ||
// (step 10d) | ||
assert.throws(RangeError, () => lastMonth.subtract({seconds: 1})); | ||
assert.throws(RangeError, () => lastMonth.subtract({minutes: 1})); | ||
assert.throws(RangeError, () => lastMonth.subtract({hours: 1})); | ||
assert.throws(RangeError, () => lastMonth.subtract({days: 1})); | ||
assert.throws(RangeError, () => lastMonth.subtract({weeks: 1})); | ||
assert.throws(RangeError, () => lastMonth.subtract({months: 1})); | ||
assert.throws(RangeError, () => lastMonth.subtract({years: 1})); | ||
|