Skip to content

Commit d03a20e

Browse files
committed
Temporal: Add tests for PlainMonthDay.from with month and invalid monthCode
1 parent 42303c7 commit d03a20e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/built-ins/Temporal/PlainMonthDay/from/monthcode-invalid.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ features: [Temporal]
99

1010
["m1", "M1", "m01"].forEach((monthCode) => {
1111
assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ monthCode, day: 17 }),
12-
`monthCode '${monthCode}' is not well-formed`);
12+
`monthCode '${monthCode}' is not well-formed (without numeric month)`);
13+
assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ month: 1, monthCode, day: 17 }),
14+
`monthCode '${monthCode}' is not well-formed (with numeric month)`);
1315
});
1416

1517
assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ year: 2021, month: 12, monthCode: "M11", day: 17 }),
1618
"monthCode and month conflict");
1719

1820
["M00", "M19", "M99", "M13", "M00L", "M05L", "M13L"].forEach((monthCode) => {
1921
assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ monthCode, day: 17 }),
20-
`monthCode '${monthCode}' is not valid for ISO 8601 calendar`);
22+
`monthCode '${monthCode}' is not valid for ISO 8601 calendar (without numeric month)`);
23+
var plausibleMonth = Number(monthCode.slice(1, 3)) + (monthCode.length - 3);
24+
assert.throws(
25+
RangeError,
26+
() => Temporal.PlainMonthDay.from({ month: plausibleMonth, monthCode, day: 17 }),
27+
`monthCode '${monthCode}' is not valid for ISO 8601 calendar (with numeric month)`
28+
);
2129
});
2230

2331
assert.throws(

0 commit comments

Comments
 (0)