Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Duration/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.duration.from
7 description: Basic string arguments.
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 TemporalHelpers.assertDuration(Temporal.Duration.from("P1D"),
13 0, 0, 0, 1, 0, 0, 0, 0, 0, 0);
14 TemporalHelpers.assertDuration(Temporal.Duration.from("p1y1m1dt1h1m1s"),
15 1, 1, 0, 1, 1, 1, 1, 0, 0, 0);
16 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.1S"),
17 1, 1, 1, 1, 1, 1, 1, 100, 0, 0);
18 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.12S"),
19 1, 1, 1, 1, 1, 1, 1, 120, 0, 0);
20 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.123S"),
21 1, 1, 1, 1, 1, 1, 1, 123, 0, 0);
22 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.1234S"),
23 1, 1, 1, 1, 1, 1, 1, 123, 400, 0);
24 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.12345S"),
25 1, 1, 1, 1, 1, 1, 1, 123, 450, 0);
26 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.123456S"),
27 1, 1, 1, 1, 1, 1, 1, 123, 456, 0);
28 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.1234567S"),
29 1, 1, 1, 1, 1, 1, 1, 123, 456, 700);
30 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.12345678S"),
31 1, 1, 1, 1, 1, 1, 1, 123, 456, 780);
32 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1.123456789S"),
33 1, 1, 1, 1, 1, 1, 1, 123, 456, 789);
34 TemporalHelpers.assertDuration(Temporal.Duration.from("P1Y1M1W1DT1H1M1,12S"),
35 1, 1, 1, 1, 1, 1, 1, 120, 0, 0);
36 TemporalHelpers.assertDuration(Temporal.Duration.from("P1DT0.5M"),
37 0, 0, 0, 1, 0, 0, 30, 0, 0, 0);
38 TemporalHelpers.assertDuration(Temporal.Duration.from("P1DT0,5H"),
39 0, 0, 0, 1, 0, 30, 0, 0, 0, 0);
40 TemporalHelpers.assertDuration(Temporal.Duration.from("+P1D"),
41 0, 0, 0, 1, 0, 0, 0, 0, 0, 0);
42 TemporalHelpers.assertDuration(Temporal.Duration.from("-P1D"),
43 0, 0, 0, -1, 0, 0, 0, 0, 0, 0);
44 TemporalHelpers.assertDuration(Temporal.Duration.from("-P1Y1M1W1DT1H1M1.123456789S"),
45 -1, -1, -1, -1, -1, -1, -1, -123, -456, -789);
46 TemporalHelpers.assertDuration(Temporal.Duration.from("PT100M"),
47 0, 0, 0, 0, 0, 100, 0, 0, 0, 0);
48
49 reportCompare(0, 0);