year-zero.js (931B)
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: Negative zero, as an extended year, fails 8 features: [Temporal] 9 ---*/ 10 11 const instance = new Temporal.ZonedDateTime(0n, "UTC"); 12 const invalidStrings = [ 13 "-0000000-01-01T00:02Z[UTC]", 14 "-0000000-01-01T00:02+00:00[UTC]", 15 "-0000000-01-01T00:02:00.000000000+00:00[UTC]", 16 ]; 17 18 invalidStrings.forEach((arg) => { 19 assert.throws(RangeError, 20 () => Temporal.ZonedDateTime.compare(arg, instance), 21 "cannot use negative zero as extended year (first argument)" 22 ); 23 assert.throws(RangeError, 24 () => Temporal.ZonedDateTime.compare(instance, arg), 25 "cannot use negative zero as extended year (second argument)" 26 ); 27 }); 28 29 reportCompare(0, 0);