Skip to content

Commit 3eea1a7

Browse files
ptomatorwaldron
authored andcommittedMar 29, 2022
Add tests for various invalid ISO strings for PlainDate
These tests check API entry points that convert strings to Temporal.PlainDate, with a list of various strings that are all not valid for that context according to ISO 8601.
1 parent ad74a4e commit 3eea1a7

25 files changed

+1535
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.dateadd
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.dateAdd(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright (C) 2022 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.calendar.prototype.dateuntil
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a %%%conversion_target%%%
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
const other = new Temporal.PlainDate(2020, 1, 1, instance);
56+
for (const arg of invalidStrings) {
57+
assert.throws(
58+
RangeError,
59+
() => instance.dateUntil(arg, other),
60+
`"${arg}" should not be a valid ISO string for a PlainDate (first argument)`
61+
);
62+
assert.throws(
63+
RangeError,
64+
() => instance.dateUntil(other, arg),
65+
`"${arg}" should not be a valid ISO string for a PlainDate (second argument)`
66+
);
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.day
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.day(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.dayofweek
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.dayOfWeek(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.dayofyear
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.dayOfYear(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.daysinmonth
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.daysInMonth(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.daysinweek
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.daysInWeek(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.daysinyear
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.daysInYear(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.inleapyear
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.inLeapYear(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.month
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.month(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.monthcode
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.monthCode(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.monthsinyear
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.monthsInYear(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.weekofyear
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.weekOfYear(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.year
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.year(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (C) 2022 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.compare
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a %%%conversion_target%%%
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const other = new Temporal.PlainDate(2020, 1, 1);
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => Temporal.PlainDate.compare(arg, other),
59+
`"${arg}" should not be a valid ISO string for a PlainDate (first argument)`
60+
);
61+
assert.throws(
62+
RangeError,
63+
() => Temporal.PlainDate.compare(other, arg),
64+
`"${arg}" should not be a valid ISO string for a PlainDate (second argument)`
65+
);
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (C) 2022 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: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
for (const arg of invalidStrings) {
55+
assert.throws(
56+
RangeError,
57+
() => Temporal.PlainDate.from(arg),
58+
`"${arg}" should not be a valid ISO string for a PlainDate`
59+
);
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.prototype.equals
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.PlainDate(2000, 5, 2);
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.equals(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.prototype.since
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.PlainDate(2000, 5, 2);
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.since(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.prototype.until
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.PlainDate(2000, 5, 2);
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.until(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.withplaindate
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.withPlainDate(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.plaintime.prototype.toplaindatetime
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.toPlainDateTime(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.plaintime.prototype.tozoneddatetime
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.toZonedDateTime({ plainDate: arg }),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.prototype.withplaindate
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.withPlainDate(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.era
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.era(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (C) 2022 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.calendar.prototype.erayear
6+
description: >
7+
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
8+
that is not supported) is used as a PlainDate
9+
features: [Temporal, arrow-function]
10+
---*/
11+
12+
const invalidStrings = [
13+
// invalid ISO strings:
14+
"",
15+
"invalid iso8601",
16+
"2020-01-00",
17+
"2020-01-32",
18+
"2020-02-30",
19+
"2021-02-29",
20+
"2020-00-01",
21+
"2020-13-01",
22+
"2020-01-01T",
23+
"2020-01-01T25:00:00",
24+
"2020-01-01T01:60:00",
25+
"2020-01-01T01:60:61",
26+
"2020-01-01junk",
27+
"2020-01-01T00:00:00junk",
28+
"2020-01-01T00:00:00+00:00junk",
29+
"2020-01-01T00:00:00+00:00[UTC]junk",
30+
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
31+
"02020-01-01",
32+
"2020-001-01",
33+
"2020-01-001",
34+
"2020-01-01T001",
35+
"2020-01-01T01:001",
36+
"2020-01-01T01:01:001",
37+
// valid, but forms not supported in Temporal:
38+
"2020-W01-1",
39+
"2020-001",
40+
"+0002020-01-01",
41+
// valid, but this calendar must not exist:
42+
"2020-01-01[u-ca=notexist]",
43+
// may be valid in other contexts, but insufficient information for PlainDate:
44+
"2020-01",
45+
"+002020-01",
46+
"01-01",
47+
"2020-W01",
48+
"P1Y",
49+
"-P12Y",
50+
// valid, but outside the supported range:
51+
"-999999-01-01",
52+
"+999999-01-01",
53+
];
54+
const instance = new Temporal.Calendar("iso8601");
55+
for (const arg of invalidStrings) {
56+
assert.throws(
57+
RangeError,
58+
() => instance.eraYear(arg),
59+
`"${arg}" should not be a valid ISO string for a PlainDate`
60+
);
61+
}

0 commit comments

Comments
 (0)
Please sign in to comment.