offset-string-invalid.js (1161B)
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.zoneddatetime.from 7 description: Validation of monthCode 8 features: [Temporal] 9 ---*/ 10 11 const bag = { year: 2024, monthCode: "M10", day: 3, timeZone: "UTC" }; 12 13 ["garbage", "00:00", "+000:00", "-00:000", "-00:00:000", "+00:00.0", "+00:00:00.0000000000"].forEach((offset) => { 14 assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ offset, year: 2024, monthCode: "M10", day: 3, timeZone: "UTC" }), 15 `UTC offset '${offset}' is not well-formed`); 16 }); 17 18 assert.throws( 19 RangeError, 20 () => Temporal.ZonedDateTime.from({ offset: "--00:00", year: Symbol(), monthCode: "M10", day: 3, timeZone: "UTC" }), 21 "UTC offset syntax is validated before year type is validated" 22 ); 23 24 assert.throws( 25 TypeError, 26 () => Temporal.ZonedDateTime.from({ offset: "+04:30", year: Symbol(), monthCode: "M10", day: 3, timeZone: "UTC" }), 27 "UTC offset matching is validated after year type is validated" 28 ); 29 30 reportCompare(0, 0);