test262/test/built-ins/Temporal/PlainTime/compare/argument-string-time-separators.js
Philip Chimento 579268ab79 Temporal: Add tests for variant time separators
ISO strings may separate the time from the date with a case-insensitive T,
or a space. This adds tests to all entry points that take ISO strings, to
ensure that they accept an uppercase T, lowercase T, or space as the time
separator.

These tests are based on the one test for Temporal.PlainDateTime.from that
was already present.
2022-05-23 11:47:56 +02:00

32 lines
952 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.compare
description: Time separator in string argument can vary
features: [Temporal]
---*/
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const tests = [
["1976-11-18T12:34:56.987654321", "uppercase T"],
["1976-11-18t12:34:56.987654321", "lowercase T"],
["1976-11-18 12:34:56.987654321", "space between date and time"],
["T12:34:56.987654321", "time-only uppercase T"],
["t12:34:56.987654321", "time-only lowercase T"],
];
tests.forEach(([arg, description]) => {
assert.sameValue(
Temporal.PlainTime.compare(arg, plainTime),
0,
`variant time separators (${description}), first argument`
);
assert.sameValue(
Temporal.PlainTime.compare(plainTime, arg),
0,
`variant time separators (${description}), second argument`
);
});