test262/test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-options-undefined.js
Philip Chimento ac19506a01 Add tests ensuring that observable calls are made with options === undefined
Where possible, observable calls originating from within Temporal, that
require an options argument, should pass `undefined` as that options
argument, rather than `{}` or `Object.create(null)`.

See tc39/proposal-temporal#1685.
2022-04-04 16:24:17 -04:00

23 lines
910 B
JavaScript

// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.duration.compare
description: >
BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the
options value
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const calendar = TemporalHelpers.calendarDateAddUndefinedOptions();
const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9);
const relativeTo = new Temporal.ZonedDateTime(0n, timeZone, calendar);
const duration1 = new Temporal.Duration(0, 0, 1);
const duration2 = new Temporal.Duration(0, 0, 1);
Temporal.Duration.compare(duration1, duration2, { relativeTo });
assert.sameValue(calendar.dateAddCallCount, 4);
// one call in CalculateOffsetShift for each duration argument, plus one in
// UnbalanceDurationRelative for each duration argument