mirror of
https://github.com/tc39/test262.git
synced 2025-08-21 01:48:30 +02:00
This adds an object, TemporalHelpers.ISO, which has methods that return arrays of various ISO strings. The idea is to deduplicate more string tests into methods on this object.
33 lines
1012 B
JavaScript
33 lines
1012 B
JavaScript
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: sec-temporal.plaintime.from
|
|
description: ISO 8601 time designator "T" required in cases of ambiguity
|
|
includes: [temporalHelpers.js]
|
|
features: [Temporal, arrow-function]
|
|
---*/
|
|
|
|
TemporalHelpers.ISO.plainTimeStringsAmbiguous().forEach((string) => {
|
|
let arg = string;
|
|
assert.throws(
|
|
RangeError,
|
|
() => Temporal.PlainTime.from(arg),
|
|
`'${arg}' is ambiguous and requires T prefix`
|
|
);
|
|
// The same string with a T prefix should not throw:
|
|
arg = `T${string}`;
|
|
Temporal.PlainTime.from(arg);
|
|
|
|
arg = ` ${string}`;
|
|
assert.throws(
|
|
RangeError,
|
|
() => Temporal.PlainTime.from(arg),
|
|
`space is not accepted as a substitute for T prefix: '${arg}'`
|
|
);
|
|
});
|
|
|
|
// None of these should throw without a T prefix, because they are unambiguously time strings:
|
|
TemporalHelpers.ISO.plainTimeStringsUnambiguous().forEach(
|
|
(arg) => Temporal.PlainTime.from(arg));
|