Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-year-zero.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
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, is rejected
8 features: [Temporal, arrow-function]
9 ---*/
10
11 const datetime = new Temporal.ZonedDateTime(0n, "UTC");
12 const invalidStrings = [
13 "-000000-10-31T17:45Z",
14 "-000000-10-31T17:45+00:00[UTC]",
15 ];
16 invalidStrings.forEach((timeZone) => {
17 assert.throws(
18 RangeError,
19 () => Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, datetime),
20 "reject minus zero as extended year (first argument)"
21 );
22 assert.throws(
23 RangeError,
24 () => Temporal.ZonedDateTime.compare(datetime, { year: 2020, month: 5, day: 2, timeZone }),
25 "reject minus zero as extended year (second argument)"
26 );
27 });
28
29 reportCompare(0, 0);