Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/limits.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.plainyearmonth.from
7 description: PlainYearMonth.from enforces the supported range
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 ["reject", "constrain"].forEach((overflow) => {
13 [{ year: -271821, month: 3 }, { year: 275760, month: 10 }, "-271821-03", "+275760-10"].forEach((value) => {
14 assert.throws(RangeError, () => Temporal.PlainYearMonth.from(value, { overflow }),
15 `${JSON.stringify(value)} with ${overflow}`);
16 });
17 });
18
19 TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from({ year: -271821, month: 4 }),
20 -271821, 4, "M04", "min object");
21 TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from({ year: 275760, month: 9 }),
22 275760, 9, "M09", "max object");
23 TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from("-271821-04"),
24 -271821, 4, "M04", "min string");
25 TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from("+275760-09"),
26 275760, 9, "M09", "max string");
27
28 reportCompare(0, 0);