Skip to content

Commit 2d6491a

Browse files
Brage Hogstadbrageh01
Brage Hogstad
authored andcommitted
Merge and extract for PlainDateTime/prototype withCalendar
1 parent 3b39021 commit 2d6491a

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.prototype.withcalendar
6+
description: Invalid ISO 8601 string is not accepted as calendar
7+
features: [Temporal]
8+
---*/
9+
10+
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601");
11+
12+
const invalidStrings = [
13+
["", "empty string"],
14+
["1997-12-04[u-ca=iso8601]", "ISO string with calendar annotation"],
15+
];
16+
17+
for (const [arg, description] of invalidStrings) {
18+
assert.throws(
19+
RangeError,
20+
() => instance.withCalendar(arg),
21+
`${description} is not a valid calendar ID`
22+
);
23+
}

test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-number.js

-25
This file was deleted.

test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-wrong-type.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456,
1414
const primitiveTests = [
1515
[null, "null"],
1616
[true, "boolean"],
17-
["", "empty string"],
1817
[1, "number that doesn't convert to a valid ISO string"],
1918
[1n, "bigint"],
19+
[19970327, "large number"],
20+
[-19970327, "negative number"],
21+
[1234567890, "very large integer"],
2022
];
2123

2224
for (const [arg, description] of primitiveTests) {
2325
assert.throws(
24-
typeof arg === 'string' ? RangeError : TypeError,
26+
TypeError,
2527
() => instance.withCalendar(arg),
2628
`${description} does not convert to a valid ISO string`
2729
);

0 commit comments

Comments
 (0)