invalid-month-codes-hebrew.js (1530B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2025 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.plainmonthday.from 7 description: Month codes that are invalid for Hebrew calendar 8 features: [Temporal, Intl.Era-monthcode] 9 ---*/ 10 11 // The Hebrew calendar is a 12-month lunisolar calendar with leap month M05L 12 // (Adar I) but does not have a thirteenth month (M13) 13 14 const calendar = "hebrew"; 15 16 assert.throws(RangeError, () => { 17 Temporal.PlainMonthDay.from({ calendar, monthCode: "M13", day: 1 }); 18 }, `M13 should not be a valid month code for ${calendar} calendar`); 19 20 // M13 should throw even with overflow: "constrain" 21 assert.throws(RangeError, () => { 22 Temporal.PlainMonthDay.from({ calendar, monthCode: "M13", day: 1 }, { overflow: "constrain" }); 23 }, `M13 should not be valid for ${calendar} calendar even with constrain overflow`); 24 25 // M13 should throw with overflow: "reject" 26 assert.throws(RangeError, () => { 27 Temporal.PlainMonthDay.from({ calendar, monthCode: "M13", day: 1 }, { overflow: "reject" }); 28 }, `M13 should not be valid for ${calendar} calendar with reject overflow`); 29 30 // Invalid leap months: e.g. M02L 31 for (var i = 1; i <= 12; i++) { 32 if (i === 5) 33 continue; 34 const monthCode = `M${ i.toString().padStart(2, "0") }L`; 35 assert.throws(RangeError, function () { 36 Temporal.PlainMonthDay.from({ monthCode, day: 1, calendar }); 37 }); 38 } 39 40 reportCompare(0, 0);