Debian Codegraph @

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