argument-propertybag-calendar-invalid-iso-string.js (987B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2025 Brage Hogstad, University of Bergen. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.zoneddatetime.compare 7 description: Invalid ISO string as calendar should throw RangeError 8 features: [Temporal] 9 ---*/ 10 11 const datetime = new Temporal.ZonedDateTime(0n, "UTC"); 12 13 const invalidStrings = [ 14 ["", "empty string"], 15 ]; 16 17 for (const [calendar, description] of invalidStrings) { 18 const arg = { year: 1970, monthCode: "M01", day: 1, calendar, timeZone: "UTC" }; 19 assert.throws( 20 RangeError, 21 () => Temporal.ZonedDateTime.compare(arg, datetime), 22 `${description} is not a valid calendar ID (first argument)` 23 ); 24 assert.throws( 25 RangeError, 26 () => Temporal.ZonedDateTime.compare(datetime, arg), 27 `${description} is not a valid calendar ID (second argument)` 28 ); 29 } 30 31 reportCompare(0, 0);