@@ -9,15 +9,29 @@ 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
1517assert . 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 monthNumber = Number ( monthCode . slice ( 1 , 3 ) ) + ( monthCode . length - 3 ) ;
24+ assert . throws (
25+ RangeError ,
26+ ( ) => Temporal . PlainMonthDay . from ( { month : monthNumber , monthCode, day : 17 } ) ,
27+ `monthCode '${ monthCode } ' is not valid for ISO 8601 calendar (with numeric month)`
28+ ) ;
29+ var clampedMonthNumber = monthNumber < 1 ? 1 : monthNumber > 12 ? 12 : monthNumber ;
30+ assert . throws (
31+ RangeError ,
32+ ( ) => Temporal . PlainMonthDay . from ( { month : clampedMonthNumber , monthCode, day : 17 } ) ,
33+ `monthCode '${ monthCode } ' is not valid for ISO 8601 calendar (with clamped numeric month)`
34+ ) ;
2135} ) ;
2236
2337assert . throws (
0 commit comments