Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for adding negative durations to/subtracting durations from the last representable year/month of the ISO calendar #4302

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}));

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}));

Loading