summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/limits.js
blob: 2cc1f868bdbeb030d048541f83610623195fc500 (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.plainyearmonth.from
description: PlainYearMonth.from enforces the supported range
includes: [temporalHelpers.js]
features: [Temporal]
---*/

["reject", "constrain"].forEach((overflow) => {
  [{ year: -271821, month: 3 }, { year: 275760, month: 10 }, "-271821-03", "+275760-10"].forEach((value) => {
    assert.throws(RangeError, () => Temporal.PlainYearMonth.from(value, { overflow }),
      `${JSON.stringify(value)} with ${overflow}`);
  });
});

TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from({ year: -271821, month: 4 }),
  -271821, 4, "M04", "min object");
TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from({ year: 275760, month: 9 }),
  275760, 9, "M09", "max object");
TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from("-271821-04"),
  -271821, 4, "M04", "min string");
TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from("+275760-09"),
  275760, 9, "M09", "max string");

reportCompare(0, 0);