Skip to content

Commit 334bb5d

Browse files
anbaptomato
authored andcommitted
Test that resolved MonthDay can have a different ordinal month
PR #4708 covered the second issue reported in <https://bugzilla.mozilla.org/show_bug.cgi?id=1999918>. Extend the test cases to also cover the first issue reported there.
1 parent a1f905d commit 334bb5d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/intl402/Temporal/PlainMonthDay/from/calendarresolvefields-error-ordering-chinese.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@ assert.throws(
5151
() => Temporal.PlainMonthDay.from({ calendar: "chinese", year: 2020, monthCode: "M01", day: 32 }, { overflow: "reject" }),
5252
"Out-of-range day throws RangeError when all required fields present"
5353
);
54+
55+
// No RangeError if month is present and reference date has a different ordinal month.
56+
var pmd = Temporal.PlainMonthDay.from({ calendar: "chinese", year: 2004, monthCode: "M04", month: 5, day: 1 });
57+
var pd = Temporal.PlainDate.from(pmd.toString());
58+
assert.sameValue(pmd.monthCode, "M04", "Temporal.PlainMonthDay monthCode");
59+
assert.sameValue(pd.monthCode, "M04", "Temporal.PlainDate monthCode");
60+
assert.sameValue(pd.month, 4, "Temporal.PlainDate ordinal month");

test/intl402/Temporal/PlainMonthDay/from/calendarresolvefields-error-ordering-hebrew.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ assert.throws(
5050
() => Temporal.PlainMonthDay.from({ calendar: "hebrew", year: 5784, monthCode: "M01", day: 32 }, { overflow: "reject" }),
5151
"Out-of-range day throws RangeError when all required fields present"
5252
);
53+
54+
// No RangeError if month is present and reference date has a different ordinal month.
55+
var pmd = Temporal.PlainMonthDay.from({ calendar: "hebrew", year: 5784, monthCode: "M06", month: 7, day: 1 });
56+
var pd = Temporal.PlainDate.from(pmd.toString());
57+
assert.sameValue(pmd.monthCode, "M06", "Temporal.PlainMonthDay monthCode");
58+
assert.sameValue(pd.monthCode, "M06", "Temporal.PlainDate monthCode");
59+
assert.sameValue(pd.month, 6, "Temporal.PlainDate ordinal month");

0 commit comments

Comments
 (0)