argument-string-calendar-annotation-invalid-key.js (1076B)
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.compare 7 description: Annotation keys are lowercase-only 8 features: [Temporal] 9 ---*/ 10 11 const datetime = new Temporal.ZonedDateTime(0n, "UTC"); 12 13 const invalidStrings = [ 14 ["1970-01-01T00:00[UTC][U-CA=iso8601]", "invalid capitalized key"], 15 ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], 16 ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], 17 ]; 18 19 invalidStrings.forEach(([arg, descr]) => { 20 assert.throws( 21 RangeError, 22 () => Temporal.ZonedDateTime.compare(arg, datetime), 23 `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` 24 ); 25 assert.throws( 26 RangeError, 27 () => Temporal.ZonedDateTime.compare(datetime, arg), 28 `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` 29 ); 30 }); 31 32 reportCompare(0, 0);