From bcb409148dc69065aba920ca4fd00d54988056b6 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 18 May 2023 09:53:12 -0700 Subject: [PATCH] Temporal: Remove loops in RoundDuration --- ...r-dateadd-called-with-options-undefined.js | 5 +- ...euntil-called-with-singular-largestunit.js | 2 +- ...ration-out-of-range-added-to-relativeto.js | 4 ++ .../prototype/round/order-of-operations.js | 42 ++++++------ ...euntil-called-with-singular-largestunit.js | 28 +------- ...ration-out-of-range-added-to-relativeto.js | 4 ++ .../prototype/total/order-of-operations.js | 64 ++++++++++--------- .../prototype/since/order-of-operations.js | 29 ++++----- .../prototype/until/order-of-operations.js | 29 ++++----- .../prototype/since/order-of-operations.js | 30 ++++----- .../prototype/until/order-of-operations.js | 30 ++++----- ...euntil-called-with-singular-largestunit.js | 4 +- .../prototype/since/order-of-operations.js | 22 +++---- ...euntil-called-with-singular-largestunit.js | 4 +- .../prototype/until/order-of-operations.js | 22 +++---- 15 files changed, 155 insertions(+), 164 deletions(-) diff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-options-undefined.js index c880c823a3..3d16c0dd5c 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-options-undefined.js +++ b/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-options-undefined.js @@ -33,8 +33,7 @@ assert.sameValue(calendar.dateAddCallCount, 3, "rounding with calendar smallestU // The calls come from these paths: // Duration.round() -> // UnbalanceDurationRelative -> MoveRelativeDate -> calendar.dateAdd() -// RoundDuration -> -// MoveRelativeDate -> calendar.dateAdd() (5x) +// RoundDuration -> MoveRelativeDate -> calendar.dateAdd() (2x) // BalanceDateDurationRelative -> calendar.dateAdd() // MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() @@ -42,7 +41,7 @@ calendar.dateAddCallCount = 0; const instance2 = new Temporal.Duration(0, 1, 1, 1); instance2.round({ largestUnit: "weeks", smallestUnit: "weeks", relativeTo }); -assert.sameValue(calendar.dateAddCallCount, 8, "rounding with non-default largestUnit and calendar smallestUnit"); +assert.sameValue(calendar.dateAddCallCount, 5, "rounding with non-default largestUnit and calendar smallestUnit"); // Rounding with smallestUnit days only. // The calls come from these paths: diff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js index a1d8343c6a..918c195129 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js +++ b/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js @@ -148,7 +148,7 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( }, { years: ["year"], months: ["month"], - weeks: ["week"], + weeks: ["week", "week"], days: [] } ); diff --git a/test/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js b/test/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js index befa334f5f..dbc2e00f6a 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js +++ b/test/built-ins/Temporal/Duration/prototype/round/duration-out-of-range-added-to-relativeto.js @@ -16,6 +16,10 @@ info: | const instance = new Temporal.Duration(0, 0, 0, /* days = */ 500_000_000); const relativeTo = new Temporal.PlainDate(2000, 1, 1); assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "years"})); +assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "months"})); +assert.throws(RangeError, () => instance.round({relativeTo, smallestUnit: "weeks"})); const negInstance = new Temporal.Duration(0, 0, 0, /* days = */ -500_000_000); assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "years"})); +assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "months"})); +assert.throws(RangeError, () => negInstance.round({relativeTo, smallestUnit: "weeks"})); diff --git a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js index 9fac23df5d..b42a868e63 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js @@ -133,11 +133,11 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest year: const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 7.e - "call options.relativeTo.calendar.dateAdd", // 7.g - "call options.relativeTo.calendar.dateUntil", // 7.o - "call options.relativeTo.calendar.dateAdd", // 7.s MoveRelativeDate - "call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.d + "call options.relativeTo.calendar.dateAdd", // 12.f + "call options.relativeTo.calendar.dateUntil", // 12.n + "call options.relativeTo.calendar.dateAdd", // 12.r MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.x MoveRelativeDate // BalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 9.c "call options.relativeTo.calendar.dateUntil", // 9.d @@ -153,10 +153,11 @@ const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([ "call options.relativeTo.calendar.dateAdd", // 3.f "call options.relativeTo.calendar.dateUntil", // 3.i // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 10.c - "call options.relativeTo.calendar.dateAdd", // 10.e - "call options.relativeTo.calendar.dateAdd", // 10.k MoveRelativeDate -], Array(2).fill("call options.relativeTo.calendar.dateAdd"), [ // 2× 10.n.iii MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 13.c + "call options.relativeTo.calendar.dateAdd", // 13.e + "call options.relativeTo.calendar.dateUntil", // 13.m + "call options.relativeTo.calendar.dateAdd", // 13.q MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 10.d "call options.relativeTo.calendar.dateUntil", // 10.e @@ -171,8 +172,9 @@ const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([ // UnbalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 4.e // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 11.d MoveRelativeDate -], Array(58).fill("call options.relativeTo.calendar.dateAdd"), [ // 58× 11.g.iii MoveRelativeDate (52 + 4 + 2) + "call options.relativeTo.calendar.dateUntil", // 14.f + "call options.relativeTo.calendar.dateAdd", // 14.j MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 16 "call options.relativeTo.calendar.dateUntil", // 17 @@ -204,9 +206,9 @@ actual.splice(0); // clear // code path through Duration.prototype.round balancing from months up to years: const expectedOpsForMonthToYearBalancing = expectedOpsForPlainRelativeTo.concat([ // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 10.c - "call options.relativeTo.calendar.dateAdd", // 10.e - "call options.relativeTo.calendar.dateAdd", // 10.k MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 13.c + "call options.relativeTo.calendar.dateAdd", // 13.e + "call options.relativeTo.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 9.c "call options.relativeTo.calendar.dateUntil", // 9.d @@ -387,11 +389,11 @@ const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ "call options.relativeTo.timeZone.getPossibleInstantsFor", // NanosecondsToDays → AddDaysToZonedDateTime "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.calendar.dateAdd", // 7.e - "call options.relativeTo.calendar.dateAdd", // 7.g - "call options.relativeTo.calendar.dateUntil", // 7.o - "call options.relativeTo.calendar.dateAdd", // 7.s MoveRelativeDate - "call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.d + "call options.relativeTo.calendar.dateAdd", // 12.f + "call options.relativeTo.calendar.dateUntil", // 12.n + "call options.relativeTo.calendar.dateAdd", // 12.r MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.x MoveRelativeDate // BalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 9.c "call options.relativeTo.calendar.dateUntil", // 9.d @@ -417,7 +419,7 @@ const expectedOpsForUnbalanceRoundBalance = expectedOpsForZonedRelativeTo.concat "call options.relativeTo.calendar.dateAdd", "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 8.g MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 10.d "call options.relativeTo.calendar.dateUntil", // 10.e diff --git a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/Duration/prototype/total/calendar-dateuntil-called-with-singular-largestunit.js index 964e2dfd6e..d7f0a65ad3 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateuntil-called-with-singular-largestunit.js +++ b/test/built-ins/Temporal/Duration/prototype/total/calendar-dateuntil-called-with-singular-largestunit.js @@ -39,8 +39,8 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -// Check the paths that go through NanosecondsToDays: only one call with -// largestUnit: "year" in RoundDuration when the unit is "year". The others all +// Check the paths that go through NanosecondsToDays: only one call in +// RoundDuration when the unit is a calendar unit. The others all // have largestUnit: "day" so the difference is taken in ISO calendar space. const duration = new Temporal.Duration(0, 1, 1, 1, 1, 1, 1, 1, 1, 1); @@ -50,32 +50,10 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", calendar); duration.total({ unit, relativeTo }); }, - { - years: ["year"], - months: [], - weeks: [], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); - -// Check the path that converts years to months in UnbalanceDurationRelative. - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, unit) => { - const duration = new Temporal.Duration(5, 1); - const relativeTo = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 0, 0, 0, calendar); - duration.total({ unit, relativeTo }); - }, { years: ["year"], months: ["month"], - weeks: [], + weeks: ["week"], days: [], hours: [], minutes: [], diff --git a/test/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js b/test/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js index a5a9fc1ccf..04ab6300f5 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js +++ b/test/built-ins/Temporal/Duration/prototype/total/duration-out-of-range-added-to-relativeto.js @@ -16,6 +16,10 @@ info: | const instance = new Temporal.Duration(0, 0, 0, /* days = */ 500_000_000); const relativeTo = new Temporal.PlainDate(2000, 1, 1); assert.throws(RangeError, () => instance.total({relativeTo, unit: "years"})); +assert.throws(RangeError, () => instance.total({relativeTo, unit: "months"})); +assert.throws(RangeError, () => instance.total({relativeTo, unit: "weeks"})); const negInstance = new Temporal.Duration(0, 0, 0, /* days = */ -500_000_000); assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "years"})); +assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "months"})); +assert.throws(RangeError, () => negInstance.total({relativeTo, unit: "weeks"})); diff --git a/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js b/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js index 1df8d00f20..cafaaae372 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js @@ -105,10 +105,10 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest year with minimal calendar calls: const expectedOpsForMinimalYearRounding = expectedOpsForPlainRelativeTo.concat([ - // 7.e and 7.g not called because years, months, weeks are 0 - "call options.relativeTo.calendar.dateUntil", // 7.o - // 7.s not called because years, months, weeks are 0 - "call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate + // 12.d and 12.f not called because years, months, weeks are 0 + "call options.relativeTo.calendar.dateUntil", // 12.n + // 12.r not called because years, months, weeks are 0 + "call options.relativeTo.calendar.dateAdd", // 12.x MoveRelativeDate ]); instance.total(createOptionsObserver({ unit: "years", relativeTo: plainRelativeTo })); assert.compareArray(actual, expectedOpsForMinimalYearRounding, "order of operations with years = 0 and unit = years"); @@ -116,11 +116,11 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest year: const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 7.d - "call options.relativeTo.calendar.dateAdd", // 7.f - "call options.relativeTo.calendar.dateUntil", // 7.n - "call options.relativeTo.calendar.dateAdd", // 7.s - "call options.relativeTo.calendar.dateAdd", // 7.x MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.d + "call options.relativeTo.calendar.dateAdd", // 12.f + "call options.relativeTo.calendar.dateUntil", // 12.n + "call options.relativeTo.calendar.dateAdd", // 12.r MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.x MoveRelativeDate ]); const instanceYears = new Temporal.Duration(1, 12, 0, 0, /* hours = */ 2400); instanceYears.total(createOptionsObserver({ unit: "years", relativeTo: plainRelativeTo })); @@ -133,10 +133,12 @@ const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([ "call options.relativeTo.calendar.dateAdd", // 3.f "call options.relativeTo.calendar.dateUntil", // 3.i // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 10.c - "call options.relativeTo.calendar.dateAdd", // 10.e - "call options.relativeTo.calendar.dateAdd", // 10.k MoveRelativeDate -], Array(2).fill("call options.relativeTo.calendar.dateAdd")); // 2× 10.n.iii MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 13.c + "call options.relativeTo.calendar.dateAdd", // 13.e + "call options.relativeTo.calendar.dateUntil", // 13.m + "call options.relativeTo.calendar.dateAdd", // 13.q MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 13.w MoveRelativeDate +]); const instance2 = new Temporal.Duration(1, 0, 0, 62); instance2.total(createOptionsObserver({ unit: "months", relativeTo: plainRelativeTo })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with unit = months"); @@ -147,8 +149,10 @@ const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([ // UnbalanceDateDurationRelative "call options.relativeTo.calendar.dateAdd", // 4.e // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 11.d MoveRelativeDate -], Array(58).fill("call options.relativeTo.calendar.dateAdd")); // 58× 11.g.iii MoveRelativeDate (52 + 4 + 2) + "call options.relativeTo.calendar.dateUntil", // 14.f + "call options.relativeTo.calendar.dateAdd", // 14.j MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 14.p MoveRelativeDate +]); const instance3 = new Temporal.Duration(1, 1, 0, 15); instance3.total(createOptionsObserver({ unit: "weeks", relativeTo: plainRelativeTo })); assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with unit = weeks"); @@ -282,10 +286,10 @@ const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.con // code path through RoundDuration that rounds to the nearest year: // MoveRelativeZonedDateTime → AddDaysToZonedDateTime "call options.relativeTo.timeZone.getPossibleInstantsFor", - // 7.e and 7.g not called because years, months, weeks are 0 - "call options.relativeTo.calendar.dateUntil", // 7.o - // 7.s not called because years, months, weeks are 0 - "call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate + // 12.d and 12.f not called because years, months, weeks are 0 + "call options.relativeTo.calendar.dateUntil", // 12.n + // 12.r not called because years, months, weeks are 0 + "call options.relativeTo.calendar.dateAdd", // 12.x MoveRelativeDate ]); instance.total(createOptionsObserver({ unit: "years", relativeTo: zonedRelativeTo })); assert.compareArray( @@ -316,11 +320,11 @@ const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ "call options.relativeTo.calendar.dateAdd", "call options.relativeTo.timeZone.getPossibleInstantsFor", // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 7.e - "call options.relativeTo.calendar.dateAdd", // 7.g - "call options.relativeTo.calendar.dateUntil", // 7.o - "call options.relativeTo.calendar.dateAdd", // 7.s MoveRelativeDate - "call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.d + "call options.relativeTo.calendar.dateAdd", // 12.f + "call options.relativeTo.calendar.dateUntil", // 12.n + "call options.relativeTo.calendar.dateAdd", // 12.r MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 12.x MoveRelativeDate ]); instanceYears.total(createOptionsObserver({ unit: "years", relativeTo: zonedRelativeTo })); assert.compareArray( @@ -345,9 +349,10 @@ const expectedOpsForUnbalanceRound = expectedOpsForZonedRelativeTo.concat([ "call options.relativeTo.calendar.dateAdd", "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 7.f - "call options.relativeTo.calendar.dateAdd", // 7.h - "call options.relativeTo.calendar.dateAdd", // 7.n MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 13.c + "call options.relativeTo.calendar.dateAdd", // 13.e + "call options.relativeTo.calendar.dateUntil", // 13.m + "call options.relativeTo.calendar.dateAdd", // 13.w MoveRelativeDate ]); new Temporal.Duration(0, 1, 1).total(createOptionsObserver({ unit: "months", relativeTo: zonedRelativeTo })); assert.compareArray( @@ -375,8 +380,9 @@ const expectedOpsForBalanceRound = expectedOpsForZonedRelativeTo.concat([ // RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime "call options.relativeTo.timeZone.getPossibleInstantsFor", // 10. GetInstantFor // RoundDuration - "call options.relativeTo.calendar.dateAdd", // 10.f - "call options.relativeTo.calendar.dateAdd", // 10.i.iii + "call options.relativeTo.calendar.dateUntil", // 14.f + "call options.relativeTo.calendar.dateAdd", // 14.j MoveRelativeDate + "call options.relativeTo.calendar.dateAdd", // 14.p MoveRelativeDate ]); new Temporal.Duration(0, 0, 0, 1, 240).total(createOptionsObserver({ unit: "weeks", relativeTo: zonedRelativeTo })); assert.compareArray( diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js index 561db49f8f..885b9420f0 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js @@ -133,11 +133,11 @@ const expectedOpsForYearRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateUntil", // 7.o - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.s not called because other units can't add up to >1 year at this point) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateUntil", // 12.n + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.r not called because other units can't add up to >1 year at this point) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -161,10 +161,10 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.o not called because months and weeks == 0) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.n not called because months and weeks == 0) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -181,10 +181,9 @@ const expectedOpsForMonthRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 10.c - "call this.calendar.dateAdd", // 10.e - "call this.calendar.dateAdd", // 10.k MoveRelativeDate - // (10.n.iii MoveRelativeDate not called because weeks == 0) + "call this.calendar.dateAdd", // 13.c + "call this.calendar.dateAdd", // 13.e + "call this.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 10.d "call this.calendar.dateUntil" // 10.e @@ -201,8 +200,8 @@ const expectedOpsForWeekRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 11.d MoveRelativeDate - // (11.g.iii MoveRelativeDate not called because days already balanced) + "call this.calendar.dateUntil", // 14.f + "call this.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 16 "call this.calendar.dateUntil" // 17 diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js index 7ef94e87df..3ee157cf6a 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js @@ -134,11 +134,11 @@ const expectedOpsForYearRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateUntil", // 7.o - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.s not called because other units can't add up to >1 year at this point) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateUntil", // 12.n + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.r not called because other units can't add up to >1 year at this point) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -162,10 +162,10 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.o not called because months and weeks == 0) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.n not called because months and weeks == 0) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -182,10 +182,9 @@ const expectedOpsForMonthRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 10.c - "call this.calendar.dateAdd", // 10.e - "call this.calendar.dateAdd", // 10.k MoveRelativeDate - // (10.n.iii MoveRelativeDate not called because weeks == 0) + "call this.calendar.dateAdd", // 13.c + "call this.calendar.dateAdd", // 13.e + "call this.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 10.d "call this.calendar.dateUntil" // 10.e @@ -202,8 +201,8 @@ const expectedOpsForWeekRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 11.d MoveRelativeDate - // (11.g.iii MoveRelativeDate not called because days already balanced) + "call this.calendar.dateUntil", // 14.f + "call this.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 16 "call this.calendar.dateUntil" // 17 diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js index ee290b4bbd..ec024268f8 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js @@ -163,11 +163,11 @@ const expectedOpsForYearRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateUntil", // 7.o - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.s not called because other units can't add up to >1 year at this point) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateUntil", // 12.n + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.r not called because other units can't add up to >1 year at this point) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -197,10 +197,10 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.o not called because months and weeks == 0) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.n not called because months and weeks == 0) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -217,10 +217,10 @@ const expectedOpsForMonthRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 10.c - "call this.calendar.dateAdd", // 10.e - "call this.calendar.dateAdd", // 10.k MoveRelativeDate - // (10.n.iii MoveRelativeDate not called because weeks == 0) + "call this.calendar.dateAdd", // 13.c + "call this.calendar.dateAdd", // 13.e + "call this.calendar.dateUntil", // 13.m + "call this.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 10.d "call this.calendar.dateUntil", // 10.e @@ -237,8 +237,8 @@ const expectedOpsForWeekRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 11.d MoveRelativeDate - // (11.g.iii MoveRelativeDate not called because days already balanced) + "call this.calendar.dateUntil", // 14.f + "call this.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 16 "call this.calendar.dateUntil", // 17 diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js index 5d0fd5be04..10eb6ca7e6 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js @@ -163,11 +163,11 @@ const expectedOpsForYearRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateUntil", // 7.o - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.s not called because other units can't add up to >1 year at this point) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateUntil", // 12.n + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.r not called because other units can't add up to >1 year at this point) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -197,10 +197,10 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.o not called because months and weeks == 0) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.n not called because months and weeks == 0) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -217,10 +217,10 @@ const expectedOpsForMonthRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 10.c - "call this.calendar.dateAdd", // 10.e - "call this.calendar.dateAdd", // 10.k MoveRelativeDate - // (10.n.iii MoveRelativeDate not called because weeks == 0) + "call this.calendar.dateAdd", // 13.c + "call this.calendar.dateAdd", // 13.e + "call this.calendar.dateUntil", // 13.m + "call this.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 10.d "call this.calendar.dateUntil" // 10.e @@ -237,8 +237,8 @@ const expectedOpsForWeekRounding = expected.concat([ // CalendarDateUntil "call this.calendar.dateUntil", // RoundDuration - "call this.calendar.dateAdd", // 11.d MoveRelativeDate - // (11.g.iii MoveRelativeDate not called because days already balanced) + "call this.calendar.dateUntil", // 14.f + "call this.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 16 "call this.calendar.dateUntil" // 17 diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js index 8906592590..d446bdcdf9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js @@ -101,8 +101,8 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( }, { years: ["year", "year", "year"], - months: ["month", "month"], - weeks: ["week", "week"], + months: ["month", "month", "month"], + weeks: ["week", "week", "week"], days: [], hours: [], minutes: [], diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js index 83af2995a1..1478687e2a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js @@ -359,11 +359,11 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest year: const expectedOpsForYearRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [ // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateUntil", // 7.o - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.s not called because other units can't add up to >1 year at this point) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateUntil", // 12.n + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.r not called because other units can't add up to >1 year at this point) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -375,10 +375,10 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest month: const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [ // RoundDuration - "call this.calendar.dateAdd", // 10.c - "call this.calendar.dateAdd", // 10.e - "call this.calendar.dateAdd", // 10.k MoveRelativeDate - // (10.n.iii MoveRelativeDate not called because weeks == 0) + "call this.calendar.dateAdd", // 13.c + "call this.calendar.dateAdd", // 13.e + "call this.calendar.dateUntil", // 13.m + "call this.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 10.d "call this.calendar.dateUntil", // 10.e @@ -390,8 +390,8 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest week: const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [ // RoundDuration - "call this.calendar.dateAdd", // 11.d MoveRelativeDate - // (11.g.iii MoveRelativeDate not called because days already balanced) + "call this.calendar.dateUntil", // 14.f + "call this.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 16 "call this.calendar.dateUntil", // 17 diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js index b973b5e4c1..56a709cb59 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js @@ -101,8 +101,8 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( }, { years: ["year", "year", "year"], - months: ["month", "month"], - weeks: ["week", "week"], + months: ["month", "month", "month"], + weeks: ["week", "week", "week"], days: [], hours: [], minutes: [], diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js index 4d44545caa..23a8e3fe37 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js @@ -359,11 +359,11 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest year: const expectedOpsForYearRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [ // RoundDuration - "call this.calendar.dateAdd", // 7.e - "call this.calendar.dateAdd", // 7.g - "call this.calendar.dateUntil", // 7.o - "call this.calendar.dateAdd", // 7.y MoveRelativeDate - // (7.s not called because other units can't add up to >1 year at this point) + "call this.calendar.dateAdd", // 12.d + "call this.calendar.dateAdd", // 12.f + "call this.calendar.dateUntil", // 12.n + "call this.calendar.dateAdd", // 12.x MoveRelativeDate + // (12.r not called because other units can't add up to >1 year at this point) // BalanceDateDurationRelative "call this.calendar.dateAdd", // 9.c "call this.calendar.dateUntil" // 9.d @@ -375,10 +375,10 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest month: const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [ // RoundDuration - "call this.calendar.dateAdd", // 10.c - "call this.calendar.dateAdd", // 10.e - "call this.calendar.dateAdd", // 10.k MoveRelativeDate - // (10.n.iii MoveRelativeDate not called because weeks == 0) + "call this.calendar.dateAdd", // 13.c + "call this.calendar.dateAdd", // 13.e + "call this.calendar.dateUntil", // 13.m + "call this.calendar.dateAdd", // 13.w MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 10.d "call this.calendar.dateUntil", // 10.e @@ -390,8 +390,8 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest week: const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [ // RoundDuration - "call this.calendar.dateAdd", // 11.d MoveRelativeDate - // (11.g.iii MoveRelativeDate not called because days already balanced) + "call this.calendar.dateUntil", // 14.f + "call this.calendar.dateAdd", // 14.p MoveRelativeDate // BalanceDateDurationRelative "call this.calendar.dateAdd", // 16 "call this.calendar.dateUntil", // 17