Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-string-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) 2024 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: ISO strings at the edges of the representable range
8 features: [Temporal]
9 ---*/
10
11 const validStrings = [
12 "-271821-04",
13 "-271821-04-01",
14 "-271821-04-01T00:00",
15 "+275760-09",
16 "+275760-09-30",
17 "+275760-09-30T23:59:59.999999999",
18 ];
19
20 for (const arg of validStrings) {
21 Temporal.PlainYearMonth.from(arg);
22 }
23
24 const invalidStrings = [
25 "-271821-03-31",
26 "-271821-03-31T23:59:59.999999999",
27 "+275760-10",
28 "+275760-10-01",
29 "+275760-10-01T00:00",
30 ];
31
32 for (const arg of invalidStrings) {
33 assert.throws(
34 RangeError,
35 () => Temporal.PlainYearMonth.from(arg),
36 `"${arg}" is outside the representable range of PlainYearMonth`
37 );
38 }
39
40 reportCompare(0, 0);