From 3f4e2c24a2d53404929c90ce6f35114c62af7d8b Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 27 Sep 2023 21:55:24 -0700 Subject: [PATCH] fixup! Temporal: Precalculate PlainDateTime from ZonedDateTime in more places --- .../prototype/total/order-of-operations.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) 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 fdec380fc4d..3a8ddbd129e 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 @@ -379,3 +379,37 @@ assert.compareArray( "order of operations with unit = months and ZonedDateTime relativeTo" ); actual.splice(0); // clear + +// code path that avoids converting Zoned twice in BalanceTimeDurationRelative +const expectedOpsForBalanceRound = expectedOpsForZonedRelativeTo.concat([ + // ToTemporalDate + "get options.relativeTo.timeZone.getOffsetNanosecondsFor", + "call options.relativeTo.timeZone.getOffsetNanosecondsFor", + // No user code calls in UnbalanceDateDurationRelative + // No user code calls in AddZonedDateTime (years, months, weeks = 0) + // BalanceTimeDurationRelative + "get options.relativeTo.timeZone.getOffsetNanosecondsFor", + "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 4.a + "get options.relativeTo.timeZone.getPossibleInstantsFor", + "call options.relativeTo.timeZone.getPossibleInstantsFor", // 4.b + "get options.relativeTo.timeZone.getOffsetNanosecondsFor", + "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // NanosecondsToDays 9 + "get options.relativeTo.timeZone.getPossibleInstantsFor", + "call options.relativeTo.timeZone.getPossibleInstantsFor", // NanosecondsToDays 26 + "get options.relativeTo.timeZone.getPossibleInstantsFor", + "call options.relativeTo.timeZone.getPossibleInstantsFor", // NanosecondsToDays 31.a + // RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime + "get options.relativeTo.timeZone.getPossibleInstantsFor", // 10. GetInstantFor + "call options.relativeTo.timeZone.getPossibleInstantsFor", + // RoundDuration + "get options.relativeTo.calendar.dateAdd", // 10.d.i + "call options.relativeTo.calendar.dateAdd", // 10.f + "call options.relativeTo.calendar.dateAdd", // 10.i.iii +]); +new Temporal.Duration(0, 0, 0, 1, 240).total(createOptionsObserver({ unit: "weeks", relativeTo: zonedRelativeTo })); +assert.compareArray( + actual, + expectedOpsForBalanceRound, + "order of operations with unit = weeks and no calendar units" +); +actual.splice(0); // clear