Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDateTime/from/argument-string-subsecond.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.plaindatetime.from
7 description: Up to nine digits of sub-second precision are acceptable
8 features: [Temporal]
9 includes: [temporalHelpers.js]
10 ---*/
11
12 TemporalHelpers.assertPlainDateTime(
13 Temporal.PlainDateTime.from("1976-11-18T15:23:30.1"),
14 1976, 11, "M11", 18, 15, 23, 30, 100, 0, 0,
15 "various precisions are possible (one decimal digit)"
16 );
17
18 TemporalHelpers.assertPlainDateTime(
19 Temporal.PlainDateTime.from("1976-11-18T15:23:30.12"),
20 1976, 11, "M11", 18, 15, 23, 30, 120, 0, 0,
21 "various precisions are possible (two decimal digits)"
22 );
23
24 TemporalHelpers.assertPlainDateTime(
25 Temporal.PlainDateTime.from("1976-11-18T15:23:30.123"),
26 1976, 11, "M11", 18, 15, 23, 30, 123, 0, 0,
27 "various precisions are possible (three decimal digits)"
28 );
29
30 TemporalHelpers.assertPlainDateTime(
31 Temporal.PlainDateTime.from("1976-11-18T15:23:30.1234"),
32 1976, 11, "M11", 18, 15, 23, 30, 123, 400, 0,
33 "various precisions are possible (four decimal digits)"
34 );
35
36 TemporalHelpers.assertPlainDateTime(
37 Temporal.PlainDateTime.from("1976-11-18T15:23:30.12345"),
38 1976, 11, "M11", 18, 15, 23, 30, 123, 450, 0,
39 "various precisions are possible (five decimal digits)"
40 );
41
42 TemporalHelpers.assertPlainDateTime(
43 Temporal.PlainDateTime.from("1976-11-18T15:23:30.123456"),
44 1976, 11, "M11", 18, 15, 23, 30, 123, 456, 0,
45 "various precisions are possible (six decimal digits)"
46 );
47
48 TemporalHelpers.assertPlainDateTime(
49 Temporal.PlainDateTime.from("1976-11-18T15:23:30.1234567"),
50 1976, 11, "M11", 18, 15, 23, 30, 123, 456, 700,
51 "various precisions are possible (seven decimal digits)"
52 );
53
54 TemporalHelpers.assertPlainDateTime(
55 Temporal.PlainDateTime.from("1976-11-18T15:23:30.12345678"),
56 1976, 11, "M11", 18, 15, 23, 30, 123, 456, 780,
57 "various precisions are possible (eight decimal digits)"
58 );
59
60 TemporalHelpers.assertPlainDateTime(
61 Temporal.PlainDateTime.from("1976-11-18T15:23:30.123456789"),
62 1976, 11, "M11", 18, 15, 23, 30, 123, 456, 789,
63 "various precisions are possible (nine decimal digits)"
64 );
65
66 assert.throws(
67 RangeError,
68 () => Temporal.PlainDateTime.from("1976-11-18T15:23:30.1234567891"),
69 "ten decimal digits is too much"
70 );
71
72 reportCompare(0, 0);