test262/test/built-ins/Temporal/PlainTime/compare/argument-string-no-implicit-midnight.js
Philip Chimento 8e0c895c4d Test 'T' time designator prefix in PlainTime strings
https://github.com/tc39/proposal-temporal/pull/1952 added support for time
designator prefixes in PlainTime strings. This adds three tests to all
entry points that convert an ISO string to a PlainTime:

- no-implicit-midnight: ISO strings with only a date and no time are no
  longer accepted. Previously they were implicitly interpreted as 00:00.
- with-time-designator: Tests that various forms of string with time
  designator are correctly parsed.
- time-designator-required-for-disambiguation: Tests various cases where
  a string without a time designator is ambiguous and therefore the time
  designator is required, as well as various cases that implementations
  might assume are ambiguous but in fact are not.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
2022-02-08 15:43:25 -05:00

22 lines
709 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: RangeError thrown if a date-only string is passed in a PlainTime context
features: [Temporal, arrow-function]
---*/
const arg = "2019-10-01";
const midnight = new Temporal.PlainTime();
assert.throws(
RangeError,
() => Temporal.PlainTime.compare(arg, midnight),
"Date-only string throws, does not implicitly convert to midnight (first argument)"
);
assert.throws(
RangeError,
() => Temporal.PlainTime.compare(midnight, arg),
"Date-only string throws, does not implicitly convert to midnight (second argument)"
);