From 503d6ca8c8e8d3ac11e5508f9d5fd161cb8caac8 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 3 May 2023 12:21:56 -0700 Subject: [PATCH] Adjustments to tests for added invocations of BalanceDurationRelative In order to fix tc39/proposal-temporal#2563, we added invocations of BalanceDurationRelative after some invocations of RoundDuration. These cause observable calendar calls, which must be accounted for in some existing tests. --- .../prototype/since/order-of-operations.js | 26 ++++++++++++++--- .../prototype/until/order-of-operations.js | 26 ++++++++++++++--- .../prototype/since/order-of-operations.js | 26 ++++++++++++++--- .../prototype/until/order-of-operations.js | 26 ++++++++++++++--- .../prototype/since/order-of-operations.js | 28 ++++++++++++++++--- .../since/roundingincrement-non-integer.js | 2 +- .../prototype/until/order-of-operations.js | 28 ++++++++++++++++--- .../until/roundingincrement-non-integer.js | 2 +- ...r-dateadd-called-with-options-undefined.js | 3 +- ...euntil-called-with-singular-largestunit.js | 4 +-- .../prototype/since/order-of-operations.js | 21 ++++++++++++-- ...r-dateadd-called-with-options-undefined.js | 3 +- ...euntil-called-with-singular-largestunit.js | 4 +-- .../prototype/until/order-of-operations.js | 21 ++++++++++++-- 14 files changed, 182 insertions(+), 38 deletions(-) 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 df0b0d03122..aa45194b3ac 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 @@ -136,7 +136,13 @@ const expectedOpsForYearRounding = expected.concat([ "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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); actual.splice(0); // clear @@ -159,7 +165,13 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ "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) + // (7.o not called because months and weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.since(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); actual.splice(0); // clear @@ -175,7 +187,10 @@ const expectedOpsForMonthRounding = expected.concat([ "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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 12.b MoveRelativeDate +]); instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "months" })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); actual.splice(0); // clear @@ -189,6 +204,9 @@ const expectedOpsForWeekRounding = expected.concat([ "call this.calendar.dateUntil", // RoundDuration "call this.calendar.dateAdd", // 11.d MoveRelativeDate -]); // (11.g.iii MoveRelativeDate not called because days already balanced) + // (11.g.iii MoveRelativeDate not called because days already balanced) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 13.c MoveRelativeDate +]); instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); 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 b61c7465f5f..373072e6260 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 @@ -137,7 +137,13 @@ const expectedOpsForYearRounding = expected.concat([ "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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); actual.splice(0); // clear @@ -160,7 +166,13 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ "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) + // (7.o not called because months and weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); actual.splice(0); // clear @@ -176,7 +188,10 @@ const expectedOpsForMonthRounding = expected.concat([ "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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 12.b MoveRelativeDate +]); instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "months" })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); actual.splice(0); // clear @@ -190,6 +205,9 @@ const expectedOpsForWeekRounding = expected.concat([ "call this.calendar.dateUntil", // RoundDuration "call this.calendar.dateAdd", // 11.d MoveRelativeDate -]); // (11.g.iii MoveRelativeDate not called because days already balanced) + // (11.g.iii MoveRelativeDate not called because days already balanced) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 13.c MoveRelativeDate +]); instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); 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 ca4cde85b13..048024860f9 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 @@ -166,7 +166,13 @@ const expectedOpsForYearRounding = expected.concat([ "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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); actual.splice(0); // clear @@ -195,7 +201,13 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ "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) + // (7.o not called because months and weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); actual.splice(0); // clear @@ -211,7 +223,10 @@ const expectedOpsForMonthRounding = expected.concat([ "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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 12.b MoveRelativeDate +]); instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); actual.splice(0); // clear @@ -225,6 +240,9 @@ const expectedOpsForWeekRounding = expected.concat([ "call this.calendar.dateUntil", // RoundDuration "call this.calendar.dateAdd", // 11.d MoveRelativeDate -]); // (11.g.iii MoveRelativeDate not called because days already balanced) + // (11.g.iii MoveRelativeDate not called because days already balanced) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 13.c MoveRelativeDate +]); instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); 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 e937fdbdb6e..026a443b57c 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 @@ -166,7 +166,13 @@ const expectedOpsForYearRounding = expected.concat([ "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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); actual.splice(0); // clear @@ -195,7 +201,13 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ "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) + // (7.o not called because months and weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); actual.splice(0); // clear @@ -211,7 +223,10 @@ const expectedOpsForMonthRounding = expected.concat([ "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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 12.b MoveRelativeDate +]); instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = years"); actual.splice(0); // clear @@ -225,6 +240,9 @@ const expectedOpsForWeekRounding = expected.concat([ "call this.calendar.dateUntil", // RoundDuration "call this.calendar.dateAdd", // 11.d MoveRelativeDate -]); // (11.g.iii MoveRelativeDate not called because days already balanced) + // (11.g.iii MoveRelativeDate not called because days already balanced) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 13.c MoveRelativeDate +]); instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js index 55e4b575071..5757cce9f5f 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js @@ -161,11 +161,18 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest year: const expectedOpsForYearRounding = expected.concat([ + // 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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); actual.splice(0); // clear @@ -181,16 +188,29 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ "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) + // (7.o not called because months and weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.since(otherYearMonthPropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years"); +assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months"); actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest month: const expectedOpsForMonthRounding = expected.concat([ + // 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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 2 })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/roundingincrement-non-integer.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/roundingincrement-non-integer.js index 985ee9f20be..97513e21477 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/roundingincrement-non-integer.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/roundingincrement-non-integer.js @@ -20,5 +20,5 @@ const earlier = new Temporal.PlainYearMonth(2000, 5); const later = new Temporal.PlainYearMonth(2000, 10); const result = later.since(earlier, { roundingIncrement: 2.5, roundingMode: "trunc" }); TemporalHelpers.assertDuration(result, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, "roundingIncrement 2.5 truncates to 2"); -const result2 = later.since(earlier, { smallestUnit: "months", roundingIncrement: 1e9 + 0.5, roundingMode: "expand" }); +const result2 = later.since(earlier, { largestUnit: "months", smallestUnit: "months", roundingIncrement: 1e9 + 0.5, roundingMode: "expand" }); TemporalHelpers.assertDuration(result2, 0, 1e9, 0, 0, 0, 0, 0, 0, 0, 0, "roundingIncrement 1e9 + 0.5 truncates to 1e9"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js index cbeb40b2975..11c3d93769d 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js @@ -161,11 +161,18 @@ actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest year: const expectedOpsForYearRounding = expected.concat([ + // 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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); actual.splice(0); // clear @@ -181,17 +188,30 @@ const expectedOpsForYearRoundingSameMonth = expected.concat([ "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) + // (7.o not called because months and weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherYearMonthPropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years"); +assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months"); actual.splice(0); // clear // code path through RoundDuration that rounds to the nearest month: const expectedOpsForMonthRounding = expected.concat([ + // 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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 2 })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/roundingincrement-non-integer.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/roundingincrement-non-integer.js index 0f7f40bec57..84360e132c2 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/roundingincrement-non-integer.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/roundingincrement-non-integer.js @@ -20,5 +20,5 @@ const earlier = new Temporal.PlainYearMonth(2000, 5); const later = new Temporal.PlainYearMonth(2000, 10); const result = earlier.until(later, { roundingIncrement: 2.5, roundingMode: "trunc" }); TemporalHelpers.assertDuration(result, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, "roundingIncrement 2.5 truncates to 2"); -const result2 = earlier.until(later, { smallestUnit: "months", roundingIncrement: 1e9 + 0.5, roundingMode: "expand" }); +const result2 = earlier.until(later, { largestUnit: "months", smallestUnit: "months", roundingIncrement: 1e9 + 0.5, roundingMode: "expand" }); TemporalHelpers.assertDuration(result2, 0, 1e9, 0, 0, 0, 0, 0, 0, 0, 0, "roundingIncrement 1e9 + 0.5 truncates to 1e9"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js index ea8e220b1e8..72048fde25e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js @@ -29,8 +29,9 @@ assert.sameValue(calendar.dateAddCallCount, 1, "basic difference with largestUni // RoundDuration -> // MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() // MoveRelativeDate -> calendar.dateAdd() +// BalanceDurationRelative -> MoveRelativeDate -> calendar.dateAdd() calendar.dateAddCallCount = 0; later1.since(earlier, { smallestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 3, "rounding difference with calendar smallestUnit"); +assert.sameValue(calendar.dateAddCallCount, 4, "rounding difference with calendar smallestUnit"); 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 6f6e4eaf085..3a6248bb210 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 @@ -77,7 +77,7 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( later.since(earlier, { largestUnit, roundingIncrement: 2, roundingMode: 'ceil' }); }, { - years: ["year", "year"], + years: ["year", "year", "month"], months: ["month", "month"], weeks: ["week", "week"], days: [], @@ -100,7 +100,7 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( later.since(earlier, { smallestUnit }); }, { - years: ["year", "year"], + years: ["year", "year", "month"], months: ["month"], weeks: ["week"], days: [], 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 f232acb18d1..f52574cae72 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 @@ -358,29 +358,44 @@ 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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); 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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 12.b MoveRelativeDate +]); instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); 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) + // (11.g.iii MoveRelativeDate not called because days already balanced) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 13.c MoveRelativeDate +]); instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js index 82cdb9e137f..f09efe1221b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js @@ -29,8 +29,9 @@ assert.sameValue(calendar.dateAddCallCount, 1, "basic difference with largestUni // RoundDuration -> // MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() // MoveRelativeDate -> calendar.dateAdd() +// BalanceDurationRelative -> MoveRelativeDate -> calendar.dateAdd() calendar.dateAddCallCount = 0; earlier.until(later1, { smallestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 3, "rounding difference with calendar smallestUnit"); +assert.sameValue(calendar.dateAddCallCount, 4, "rounding difference with calendar smallestUnit"); 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 6842f08dcf8..045de138560 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 @@ -77,7 +77,7 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( earlier.until(later, { largestUnit, roundingIncrement: 2, roundingMode: 'ceil' }); }, { - years: ["year", "year"], + years: ["year", "year", "month"], months: ["month", "month"], weeks: ["week", "week"], days: [], @@ -100,7 +100,7 @@ TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( earlier.until(later, { smallestUnit }); }, { - years: ["year", "year"], + years: ["year", "year", "month"], months: ["month"], weeks: ["week"], days: [], 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 d15ccfe5a2a..893444ccec2 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 @@ -358,29 +358,44 @@ 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) + // (7.s not called because other units can't add up to >1 year at this point) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 11.c MoveRelativeDate + "call this.calendar.dateAdd", // 11.g MoveRelativeDate + "call this.calendar.dateAdd", // 11.k + "call this.calendar.dateUntil" // 11.n +]); instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); 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) + // (10.n.iii MoveRelativeDate not called because weeks == 0) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 12.b MoveRelativeDate +]); instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); 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) + // (11.g.iii MoveRelativeDate not called because days already balanced) + // BalanceDurationRelative + "call this.calendar.dateAdd", // 13.c MoveRelativeDate +]); instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); actual.splice(0); // clear