argument-string-critical-unknown-annotation.js (1090B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2022 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: Unknown annotations with critical flag are rejected 8 features: [Temporal] 9 ---*/ 10 11 const invalidStrings = [ 12 "1970-01-01T00:00[UTC][!foo=bar]", 13 "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", 14 "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", 15 "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", 16 ]; 17 18 const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); 19 20 invalidStrings.forEach((arg) => { 21 assert.throws( 22 RangeError, 23 () => Temporal.ZonedDateTime.compare(arg, datetime), 24 `reject unknown annotation with critical flag: ${arg} (first argument)` 25 ); 26 assert.throws( 27 RangeError, 28 () => Temporal.ZonedDateTime.compare(datetime, arg), 29 `reject unknown annotation with critical flag: ${arg} (second argument)` 30 ); 31 }); 32 33 reportCompare(0, 0);