monthcode-invalid.js (1325B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2024 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.plaindatetime.from 7 description: Validation of monthCode 8 features: [Temporal] 9 ---*/ 10 11 ["m1", "M1", "m01"].forEach((monthCode) => { 12 assert.throws(RangeError, () => Temporal.PlainDateTime.from({ year: 2021, monthCode, day: 17 }), 13 `monthCode '${monthCode}' is not well-formed`); 14 }); 15 16 assert.throws(RangeError, () => Temporal.PlainDateTime.from({ year: 2021, month: 12, monthCode: "M11", day: 17 }), 17 "monthCode and month conflict"); 18 19 ["M00", "M19", "M99", "M13", "M00L", "M05L", "M13L"].forEach((monthCode) => { 20 assert.throws(RangeError, () => Temporal.PlainDateTime.from({ year: 2021, monthCode, day: 17 }), 21 `monthCode '${monthCode}' is not valid for ISO 8601 calendar`); 22 }); 23 24 assert.throws( 25 RangeError, 26 () => Temporal.PlainDateTime.from({ day: 1, monthCode: "L99M", year: Symbol() }), 27 "Month code syntax is validated before year type is validated" 28 ); 29 30 assert.throws( 31 TypeError, 32 () => Temporal.PlainDateTime.from({ day: 1, monthCode: "M99L", year: Symbol() }), 33 "Month code suitability is validated after year type is validated" 34 ); 35 36 reportCompare(0, 0);