test262/test/built-ins/Temporal/PlainTime/compare/calendar-temporal-object.js

28 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (C) 2020 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: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
info: |
sec-temporal.plaintime.compare steps 12:
1. Set _one_ to ? ToTemporalTime(_one_).
2. Set _two_ to ? ToTemporalTime(_two_).
sec-temporal-totemporaltime step 3.d:
d. If _calendar_ is not *undefined*, then
i. Set _calendar_ to ? ToTemporalCalendar(_calendar_).
ii. If ? ToString(_calendar_) is not *"iso8601"*, then
1. Throw a *RangeError* exception.
sec-temporal-totemporalcalendar step 1.a:
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
i. Return _temporalCalendarLike_.[[Calendar]].
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
assert.throws(RangeError, () => Temporal.PlainTime.compare({ hour: 12, minute: 30, calendar: temporalObject }, time));
assert.throws(RangeError, () => Temporal.PlainTime.compare(time, { hour: 12, minute: 30, calendar: temporalObject }));
});