Skip to content

Commit 3b39021

Browse files
Brage Hogstadbrageh01
authored andcommitted
Merge and extract for PlainDateTime/prototype until
1 parent 588a588 commit 3b39021

File tree

3 files changed

+35
-33
lines changed

3 files changed

+35
-33
lines changed
Lines changed: 23 additions & 0 deletions
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.until
6+
description: Invalid ISO string as calendar should throw RangeError
7+
features: [Temporal]
8+
---*/
9+
10+
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
11+
12+
const invalidStrings = [
13+
["", "empty string"],
14+
];
15+
16+
for (const [calendar, description] of invalidStrings) {
17+
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
18+
assert.throws(
19+
RangeError,
20+
() => instance.until(arg),
21+
`${description} is not a valid calendar ID`
22+
);
23+
}

test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-number.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@ description: >
99
features: [BigInt, Symbol, Temporal]
1010
---*/
1111

12-
const timeZone = "UTC";
1312
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
1413

1514
const primitiveTests = [
1615
[null, "null"],
1716
[true, "boolean"],
18-
["", "empty string"],
19-
[1, "number that doesn't convert to a valid ISO string"],
17+
[1, "number"],
2018
[1n, "bigint"],
19+
[19970327, "large number"],
20+
[-19970327, "negative number"],
21+
[1234567890, "very large integer"],
2122
];
2223

2324
for (const [calendar, description] of primitiveTests) {
24-
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
25+
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
2526
assert.throws(
26-
typeof calendar === 'string' ? RangeError : TypeError,
27+
TypeError,
2728
() => instance.until(arg),
28-
`${description} does not convert to a valid ISO string`
29+
`${description} is not a valid calendar`
2930
);
3031
}
3132

@@ -37,5 +38,9 @@ const typeErrorTests = [
3738

3839
for (const [calendar, description] of typeErrorTests) {
3940
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
40-
assert.throws(TypeError, () => instance.until(arg), `${description} is not a valid property bag and does not convert to a string`);
41+
assert.throws(
42+
TypeError,
43+
() => instance.until(arg),
44+
`${description} is not a valid property bag and does not convert to a string`
45+
);
4146
}

0 commit comments

Comments
 (0)