Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDate/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) 2021 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.plaindate.from
7 description: PlainDate.from enforces the supported range
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 const tooEarly = { year: -271821, month: 4, day: 18 };
13 const tooLate = { year: 275760, month: 9, day: 14 };
14 ["reject", "constrain"].forEach((overflow) => {
15 [tooEarly, tooLate, "-271821-04-18", "+275760-09-14"].forEach((value) => {
16 assert.throws(RangeError, () => Temporal.PlainDate.from(value, { overflow }),
17 `${JSON.stringify(value)} with ${overflow}`);
18 });
19 });
20
21 TemporalHelpers.assertPlainDate(Temporal.PlainDate.from({ year: -271821, month: 4, day: 19 }),
22 -271821, 4, "M04", 19, "min object");
23 TemporalHelpers.assertPlainDate(Temporal.PlainDate.from({ year: 275760, month: 9, day: 13 }),
24 275760, 9, "M09", 13, "max object");
25
26 TemporalHelpers.assertPlainDate(Temporal.PlainDate.from("-271821-04-19"),
27 -271821, 4, "M04", 19, "min string");
28 TemporalHelpers.assertPlainDate(Temporal.PlainDate.from("+275760-09-13"),
29 275760, 9, "M09", 13, "max string");
30
31 reportCompare(0, 0);