Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / ZonedDateTime / prototype / since / calendar-dateadd-called-with-options-undefined.js
blob932847c329417ef456cd3b109130c3433aeca6b5
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 esid: sec-temporal.zoneddatetime.prototype.since
7 description: >
8     BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the
9     options value
10 includes: [temporalHelpers.js]
11 features: [Temporal]
12 ---*/
14 const calendar = TemporalHelpers.calendarDateAddUndefinedOptions();
15 const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9);
16 const earlier = new Temporal.ZonedDateTime(0n, timeZone, calendar);
17 const later = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar);
19 // Difference with rounding, with smallestUnit a calendar unit.
20 // The calls come from these paths:
21 // ZonedDateTime.since() ->
22 //   RoundDuration ->
23 //     MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd()
24 //     MoveRelativeDate -> calendar.dateAdd()
25 //   BalanceDurationRelative -> MoveRelativeDate -> calendar.dateAdd()
27 later.since(earlier, { smallestUnit: "weeks" });
28 assert.sameValue(calendar.dateAddCallCount, 3, "rounding difference with calendar smallestUnit");
30 reportCompare(0, 0);