chinese-invalid-month-code-m13.js (1294B)
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: M13 month code is invalid for Chinese calendar (12-month calendar with leap months) 8 features: [Temporal, Intl.Era-monthcode] 9 ---*/ 10 11 // The Chinese calendar is a 12-month lunisolar calendar with leap months (M01L-M12L) 12 // but does not have a thirteenth month (M13) 13 14 const calendar = "chinese"; 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 reportCompare(0, 0);