summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/PlainDate/from/limits.js
blob: 89c90bdfddd2911d7e71c59c924e6162350192db (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
29
30
31
// |reftest| skip -- Temporal is not supported
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.plaindate.from
description: PlainDate.from enforces the supported range
includes: [temporalHelpers.js]
features: [Temporal]
---*/

const tooEarly = { year: -271821, month: 4, day: 18 };
const tooLate = { year: 275760, month: 9, day: 14 };
["reject", "constrain"].forEach((overflow) => {
  [tooEarly, tooLate, "-271821-04-18", "+275760-09-14"].forEach((value) => {
    assert.throws(RangeError, () => Temporal.PlainDate.from(value, { overflow }),
      `${JSON.stringify(value)} with ${overflow}`);
  });
});

TemporalHelpers.assertPlainDate(Temporal.PlainDate.from({ year: -271821, month: 4, day: 19 }),
  -271821, 4, "M04", 19, "min object");
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from({ year: 275760, month: 9, day: 13 }),
  275760, 9, "M09", 13, "max object");

TemporalHelpers.assertPlainDate(Temporal.PlainDate.from("-271821-04-19"),
  -271821, 4, "M04", 19, "min string");
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from("+275760-09-13"),
  275760, 9, "M09", 13, "max string");

reportCompare(0, 0);