Skip to content

Commit 1697bb3

Browse files
committed
[Temporal] Add coverage for negative months and days in from
In the `from` method for the five types that can accept a month or day property, test that negative months or days throw an exception.
1 parent 9079aee commit 1697bb3

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plaindate.from
6+
description: Months and days must be non-negative integers
7+
features: [Temporal]
8+
---*/
9+
10+
assert.throws(RangeError, () => Temporal.PlainDate.from({ year: 2000, day: 1, month: -1 }));
11+
assert.throws(RangeError, () => Temporal.PlainDate.from({ year: 2000, month: 1, day: -1 }));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plaindatetime.from
6+
description: Months and days must be non-negative integers
7+
features: [Temporal]
8+
---*/
9+
10+
assert.throws(RangeError, () => Temporal.PlainDateTime.from({ year: 2000, day: 1, month: -1 }));
11+
assert.throws(RangeError, () => Temporal.PlainDateTime.from({ year: 2000, month: 1, day: -1 }));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plainmonthday.from
6+
description: Months and days must be non-negative integers
7+
features: [Temporal]
8+
---*/
9+
10+
assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ day: 1, month: -1 }));
11+
assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ month: 1, day: -1 }));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.plainyearmonth.prototype.from
6+
description: Months must be non-negative integers
7+
features: [Temporal]
8+
---*/
9+
10+
assert.throws(RangeError, () => Temporal.PlainYearMonth.from({ year: 1, month: -1 }));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.zoneddatetime.from
6+
description: Months and days must be non-negative integers
7+
features: [Temporal]
8+
---*/
9+
10+
assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ year: 2000, day: 1, timeZone: "UTC", month: -1 }));
11+
assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ year: 2000, month: 1, timeZone: "UTC", day: -1 }));

0 commit comments

Comments
 (0)