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