Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainTime/from/argument-string-time-designator-required-for-disambiguation.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.plaintime.from
7 description: ISO 8601 time designator "T" required in cases of ambiguity
8 includes: [temporalHelpers.js]
9 features: [Temporal, arrow-function]
10 ---*/
11
12 TemporalHelpers.ISO.plainTimeStringsAmbiguous().forEach((string) => {
13 let arg = string;
14 assert.throws(
15 RangeError,
16 () => Temporal.PlainTime.from(arg),
17 `'${arg}' is ambiguous and requires T prefix`
18 );
19 // The same string with a T prefix should not throw:
20 arg = `T${string}`;
21 Temporal.PlainTime.from(arg);
22
23 arg = ` ${string}`;
24 assert.throws(
25 RangeError,
26 () => Temporal.PlainTime.from(arg),
27 `space is not accepted as a substitute for T prefix: '${arg}'`
28 );
29 });
30
31 // None of these should throw without a T prefix, because they are unambiguously time strings:
32 TemporalHelpers.ISO.plainTimeStringsUnambiguous().forEach(
33 (arg) => Temporal.PlainTime.from(arg));
34
35 reportCompare(0, 0);