Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions test/built-ins/Temporal/PlainMonthDay/from/monthcode-invalid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@ features: [Temporal]

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

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

["M00", "M19", "M99", "M13", "M00L", "M05L", "M13L"].forEach((monthCode) => {
assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ monthCode, day: 17 }),
`monthCode '${monthCode}' is not valid for ISO 8601 calendar`);
`monthCode '${monthCode}' is not valid for ISO 8601 calendar (without numeric month)`);
var monthNumber = Number(monthCode.slice(1, 3)) + (monthCode.length - 3);
assert.throws(
RangeError,
() => Temporal.PlainMonthDay.from({ month: monthNumber, monthCode, day: 17 }),
`monthCode '${monthCode}' is not valid for ISO 8601 calendar (with numeric month)`
);
var clampedMonthNumber = monthNumber < 1 ? 1 : monthNumber > 12 ? 12 : monthNumber;
assert.throws(
RangeError,
() => Temporal.PlainMonthDay.from({ month: clampedMonthNumber, monthCode, day: 17 }),
`monthCode '${monthCode}' is not valid for ISO 8601 calendar (with clamped numeric month)`
);
});

assert.throws(
Expand Down