test262/test/built-ins/Temporal/ZonedDateTime/compare/timezone-string-year-zero.js
Philip Chimento 65a7ace1cb Regularize year zero tests
Some of these strings wouldn't have been valid even with a valid year in
them (e.g. strings ending in +01:00[UTC]) so fix up the strings that we
test. While touching these tests, I took the opportunity to regularize
them, and add some missing ones for ISO strings that convert to Calendar
and TimeZone.
2022-05-03 08:18:02 +02:00

38 lines
1.3 KiB
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, new Temporal.TimeZone("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)"
);
assert.throws(
RangeError,
() => Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone: { timeZone } }, datetime),
"reject minus zero as extended year (nested property, first argument)"
);
assert.throws(
RangeError,
() => Temporal.ZonedDateTime.compare(datetime, { year: 2020, month: 5, day: 2, timeZone: { timeZone } }),
"reject minus zero as extended year (nested property, second argument)"
);
});