Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Duration/from/argument-string-invalid.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: Invalid string arguments.
8 features: [Temporal]
9 ---*/
10
11 const tests = [
12 "P1Y1M1W1DT1H1M1.123456789123S",
13 "P0.5Y",
14 "P1Y0,5M",
15 "P1Y1M0.5W",
16 "P1Y1M1W0,5D",
17 "P1Y1M1W1DT0.5H5S",
18 "P1Y1M1W1DT1.5H0,5M",
19 "P1Y1M1W1DT1H0.5M0.5S",
20 "P",
21 "PT",
22 "-P",
23 "-PT",
24 "+P",
25 "+PT",
26 "P1Y1M1W1DT1H1M1.01Sjunk",
27 "P-1Y1M",
28 "P1Y-1M"
29 ];
30
31 for (const input of tests) {
32 assert.throws(RangeError, () => Temporal.Duration.from(input));
33 }
34
35 reportCompare(0, 0);