summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Instant/compare/year-zero.js
blob: eab3c98cf20ebe36a467e0ae6b6435f846a409a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// 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.instant.compare
description: Negative zero, as an extended year, fails
features: [Temporal]
---*/

const instance = new Temporal.Instant(0n);
const invalidStrings = [
  "-000000-03-30T00:45Z",
  "-000000-03-30T01:45+01:00",
  "-000000-03-30T01:45:00+00:00[UTC]",
];

invalidStrings.forEach((arg) => {
  assert.throws(RangeError,
    () => Temporal.Instant.compare(arg, instance),
    "minus zero is invalid extended year (first argument)");
  assert.throws(RangeError,
    () => Temporal.Instant.compare(instance, arg),
    "minus zero is invalid extended year (second argument)"
  );
});

reportCompare(0, 0);