Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Instant/from/argument-string.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.instant.from
7 description: Various string arguments.
8 features: [Temporal]
9 ---*/
10
11 const tests = [
12 ['1976-11-18T15:23z', 217178580000000000n],
13 ['1976-11-18T15:23:30.1Z', 217178610100000000n],
14 ['1976-11-18T15:23:30.12Z', 217178610120000000n],
15 ['1976-11-18T15:23:30.123Z', 217178610123000000n],
16 ['1976-11-18T15:23:30.1234Z', 217178610123400000n],
17 ['1976-11-18T15:23:30.12345Z', 217178610123450000n],
18 ['1976-11-18T15:23:30.123456Z', 217178610123456000n],
19 ['1976-11-18T15:23:30.1234567Z', 217178610123456700n],
20 ['1976-11-18T15:23:30.12345678Z', 217178610123456780n],
21 ['1976-11-18T15:23:30.123456789Z', 217178610123456789n],
22 ['1976-11-18T15:23:30,12Z', 217178610120000000n],
23 ['1976-11-18T15:23:30.12-02:00', 217185810120000000n],
24 ['-009999-11-18T15:23:30.12Z', -377677326989880000000n],
25 ['19761118T15:23:30.1+00:00', 217178610100000000n],
26 ['1976-11-18T152330.1+00:00', 217178610100000000n],
27 ['1976-11-18T15:23:30.1+0000', 217178610100000000n],
28 ['1976-11-18T152330.1+0000', 217178610100000000n],
29 ['19761118T15:23:30.1+0000', 217178610100000000n],
30 ['19761118T152330.1+00:00', 217178610100000000n],
31 ['+0019761118T15:23:30.1+00:00', 217178610100000000n],
32 ['+001976-11-18T152330.1+00:00', 217178610100000000n],
33 ['+001976-11-18T15:23:30.1+0000', 217178610100000000n],
34 ['+001976-11-18T152330.1+0000', 217178610100000000n],
35 ['+0019761118T15:23:30.1+0000', 217178610100000000n],
36 ['+0019761118T152330.1+00:00', 217178610100000000n],
37 ['+0019761118T152330.1+0000', 217178610100000000n],
38 ['1976-11-18T15:23:30+00', 217178610000000000n],
39 ['1976-11-18T15:23:30.123456789-00:00:00', 217178610123456789n],
40 ['1976-11-18T15:23:30.123456789-00:00:00.0', 217178610123456789n],
41 ['1976-11-18T15:23:30.123456789-00:00:00.00', 217178610123456789n],
42 ['1976-11-18T15:23:30.123456789-00:00:00.000', 217178610123456789n],
43 ['1976-11-18T15:23:30.123456789-00:00:00.0000', 217178610123456789n],
44 ['1976-11-18T15:23:30.123456789-00:00:00.00000', 217178610123456789n],
45 ['1976-11-18T15:23:30.123456789-00:00:00.000000', 217178610123456789n],
46 ['1976-11-18T15:23:30.123456789-00:00:00.0000000', 217178610123456789n],
47 ['1976-11-18T15:23:30.123456789-00:00:00.00000000', 217178610123456789n],
48 ['1976-11-18T15:23:30.123456789-00:00:00.000000000', 217178610123456789n],
49 ['1976-11-18T15:23:30.123456789-00:00:00.1', 217178610223456789n],
50 ['1976-11-18T15:23:30.123456789-00:00:00.01', 217178610133456789n],
51 ['1976-11-18T15:23:30.123456789-00:00:00.001', 217178610124456789n],
52 ['1976-11-18T15:23:30.123456789-00:00:00.0001', 217178610123556789n],
53 ['1976-11-18T15:23:30.123456789-00:00:00.00001', 217178610123466789n],
54 ['1976-11-18T15:23:30.123456789-00:00:00.000001', 217178610123457789n],
55 ['1976-11-18T15:23:30.123456789-00:00:00.0000001', 217178610123456889n],
56 ['1976-11-18T15:23:30.123456789-00:00:00.00000001', 217178610123456799n],
57 ['1976-11-18T15:23:30.123456789-00:00:00.000000001', 217178610123456790n],
58 ['1976-11-18T15:23:30.123456789-00:00:00.100000000', 217178610223456789n],
59 ['1976-11-18T15:23:30.123456789-00:00:00.010000000', 217178610133456789n],
60 ['1976-11-18T15:23:30.123456789-00:00:00.001000000', 217178610124456789n],
61 ['1976-11-18T15:23:30.123456789-00:00:00.000100000', 217178610123556789n],
62 ['1976-11-18T15:23:30.123456789-00:00:00.000010000', 217178610123466789n],
63 ['1976-11-18T15:23:30.123456789-00:00:00.000001000', 217178610123457789n],
64 ['1976-11-18T15:23:30.123456789-00:00:00.000000100', 217178610123456889n],
65 ['1976-11-18T15:23:30.123456789-00:00:00.000000010', 217178610123456799n],
66 ['1976-11-18T15Z', 217177200000000000n],
67 ['1976-11-18T15:23:30.123456789Z[u-ca=discord]', 217178610123456789n],
68 ['1976-11-18T15:23:30.123456789Z[+00]', 217178610123456789n],
69 ['1976-11-18T15:23:30.123456789Z[-00]', 217178610123456789n],
70 ['1976-11-18T15:23:30.123456789Z[-00:00]', 217178610123456789n],
71 ['1976-11-18T15:23:30.123456789Z[+12]', 217178610123456789n],
72 ['1976-11-18T15:23:30.123456789Z[NotATimeZone]', 217178610123456789n],
73 ];
74
75 for (const [arg, expected] of tests) {
76 const result = Temporal.Instant.from(arg);
77 assert.sameValue(result.epochNanoseconds, expected, `Instant.from(${arg})`);
78 }
79
80 reportCompare(0, 0);