test262/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-year-zero.js
Philip Chimento c728e6d89e Temporal: Fix tests that unnecessarily create TimeZone or Calendar instances
In many cases we created a TimeZone or Calendar instance from a built-in
time zone or calendar. These tests can be trivially adapted to just use
the string ID.
2024-07-05 10:43:53 +02:00

27 lines
854 B
JavaScript

// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.compare
description: Negative zero, as an extended year, is rejected
features: [Temporal, arrow-function]
---*/
const datetime = new Temporal.ZonedDateTime(0n, "UTC");
const invalidStrings = [
"-000000-10-31T17:45Z",
"-000000-10-31T17:45+00:00[UTC]",
];
invalidStrings.forEach((timeZone) => {
assert.throws(
RangeError,
() => Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, datetime),
"reject minus zero as extended year (first argument)"
);
assert.throws(
RangeError,
() => Temporal.ZonedDateTime.compare(datetime, { year: 2020, month: 5, day: 2, timeZone }),
"reject minus zero as extended year (second argument)"
);
});