Temporal: Make calendar method lookups unconditional

See https://github.com/tc39/proposal-temporal/issues/2724
This commit is contained in:
Philip Chimento 2023-11-10 14:40:27 -08:00 committed by Philip Chimento
parent 3e23610431
commit dc1c787cc8
20 changed files with 62 additions and 93 deletions

View File

@ -109,7 +109,6 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"has options.relativeTo.calendar.year", "has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields", "has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek", "has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields", "get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields", "get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields", "call options.relativeTo.calendar.fields",
@ -134,6 +133,8 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"get options.relativeTo.year.valueOf", "get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf",
"call options.relativeTo.calendar.dateFromFields", "call options.relativeTo.calendar.dateFromFields",
// lookup in Duration.compare
"get options.relativeTo.calendar.dateAdd",
]); ]);
const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
@ -176,7 +177,6 @@ actual.splice(0); // clear
// to days: // to days:
const expectedOpsForPlainDayBalancing = expectedOpsForPlainRelativeTo.concat( const expectedOpsForPlainDayBalancing = expectedOpsForPlainRelativeTo.concat(
[ [
"get options.relativeTo.calendar.dateAdd",
// UnbalanceDurationRelative // UnbalanceDurationRelative
"call options.relativeTo.calendar.dateAdd", // 11.a.iii.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.iii.1 MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.a.iv.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.iv.1 MoveRelativeDate
@ -264,6 +264,8 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.timeZone.getPossibleInstantsFor", "get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor", "call options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup in Duration.compare
"get options.relativeTo.calendar.dateAdd",
]); ]);
const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
@ -323,7 +325,6 @@ Temporal.Duration.compare(
assert.compareArray( assert.compareArray(
actual, actual,
expectedOpsForZonedRelativeTo.concat([ expectedOpsForZonedRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// AddZonedDateTime on first argument // AddZonedDateTime on first argument
"call options.relativeTo.calendar.dateAdd", "call options.relativeTo.calendar.dateAdd",

View File

@ -92,7 +92,6 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"has options.relativeTo.calendar.year", "has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields", "has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek", "has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields", "get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields", "get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields", "call options.relativeTo.calendar.fields",
@ -119,7 +118,7 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"call options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields // InterpretTemporalDateTimeFields
"call options.relativeTo.calendar.dateFromFields", "call options.relativeTo.calendar.dateFromFields",
// lookup 2 // lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// AddDuration // AddDuration
@ -231,6 +230,9 @@ const expectedOpsForPlainRelativeToNoCalendarOperations = [
"call options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields // InterpretTemporalDateTimeFields
"call options.relativeTo.calendar.dateFromFields", "call options.relativeTo.calendar.dateFromFields",
// lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]; ];
const noCalendarInstance = new Temporal.Duration(0, 0, 0, 4, 5, 6, 7, 987, 654, 321); const noCalendarInstance = new Temporal.Duration(0, 0, 0, 4, 5, 6, 7, 987, 654, 321);
@ -273,7 +275,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"has options.relativeTo.calendar.year", "has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields", "has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek", "has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields", "get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields", "get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields", "call options.relativeTo.calendar.fields",
@ -323,7 +324,7 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.timeZone.getPossibleInstantsFor", "get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor", "call options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup 2 // lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// AddDuration // AddDuration
@ -419,7 +420,6 @@ const expectedOpsForZonedRelativeToNoDaysOperations = [
"has options.relativeTo.calendar.year", "has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields", "has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek", "has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields", "get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields", "get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields", "call options.relativeTo.calendar.fields",
@ -469,6 +469,9 @@ const expectedOpsForZonedRelativeToNoDaysOperations = [
"get options.relativeTo.timeZone.getPossibleInstantsFor", "get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor", "call options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]; ];
const noDaysInstance = new Temporal.Duration(0, 0, 0, 0, 5, 6, 7, 987, 654, 321); const noDaysInstance = new Temporal.Duration(0, 0, 0, 0, 5, 6, 7, 987, 654, 321);

View File

@ -102,6 +102,9 @@ const expectedOpsForPlainRelativeTo = [
"get options.smallestUnit", "get options.smallestUnit",
"get options.smallestUnit.toString", "get options.smallestUnit.toString",
"call options.smallestUnit.toString", "call options.smallestUnit.toString",
// lookup in Duration.p.round
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]; ];
const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
@ -119,8 +122,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year, with minimal calendar calls: // code path through RoundDuration that rounds to the nearest year, with minimal calendar calls:
const expectedMinimalOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ const expectedMinimalOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// 7.e and 7.g not called because years, months, weeks are 0 // 7.e and 7.g not called because years, months, weeks are 0
"call options.relativeTo.calendar.dateUntil", // 7.o "call options.relativeTo.calendar.dateUntil", // 7.o
// 7.s not called because years, months, weeks are 0 // 7.s not called because years, months, weeks are 0
@ -132,8 +133,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year: // code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateAdd", // 7.e "call options.relativeTo.calendar.dateAdd", // 7.e
"call options.relativeTo.calendar.dateAdd", // 7.g "call options.relativeTo.calendar.dateAdd", // 7.g
"call options.relativeTo.calendar.dateUntil", // 7.o "call options.relativeTo.calendar.dateUntil", // 7.o
@ -152,8 +151,6 @@ actual.splice(0); // clear
// code path through Duration.prototype.round that rounds to the nearest month: // code path through Duration.prototype.round that rounds to the nearest month:
const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// UnbalanceDurationRelative // UnbalanceDurationRelative
"call options.relativeTo.calendar.dateAdd", // 9.d.i "call options.relativeTo.calendar.dateAdd", // 9.d.i
"call options.relativeTo.calendar.dateUntil", // 9.d.iv "call options.relativeTo.calendar.dateUntil", // 9.d.iv
@ -172,7 +169,6 @@ actual.splice(0); // clear
// code path through Duration.prototype.round that rounds to the nearest week: // code path through Duration.prototype.round that rounds to the nearest week:
const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// UnbalanceDurationRelative // UnbalanceDurationRelative
"call options.relativeTo.calendar.dateAdd", // 10.c.i MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 10.c.i MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.d.i MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 10.d.i MoveRelativeDate
@ -189,7 +185,6 @@ actual.splice(0); // clear
// code path through UnbalanceDurationRelative that rounds to the nearest day: // code path through UnbalanceDurationRelative that rounds to the nearest day:
const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd", // 11.a.iii.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.iii.1 MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.a.iv.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.iv.1 MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.a.v.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.v.1 MoveRelativeDate
@ -201,8 +196,6 @@ actual.splice(0); // clear
// code path through BalanceDurationRelative balancing from days up to years: // code path through BalanceDurationRelative balancing from days up to years:
const expectedOpsForDayToYearBalancing = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForDayToYearBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateAdd", // 10.b MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 10.b MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.e.iv MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 10.e.iv MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.f MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 10.f MoveRelativeDate
@ -217,8 +210,6 @@ actual.splice(0); // clear
// code path through Duration.prototype.round balancing from months up to years: // code path through Duration.prototype.round balancing from months up to years:
const expectedOpsForMonthToYearBalancing = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForMonthToYearBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// RoundDuration // RoundDuration
"call options.relativeTo.calendar.dateAdd", // 10.c "call options.relativeTo.calendar.dateAdd", // 10.c
"call options.relativeTo.calendar.dateAdd", // 10.e "call options.relativeTo.calendar.dateAdd", // 10.e
@ -237,7 +228,6 @@ assert.compareArray(actual, expectedOpsForMonthToYearBalancing, "order of operat
actual.splice(0); // clear actual.splice(0); // clear
const expectedOpsForDayToMonthBalancing = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForDayToMonthBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// BalanceDurationRelative // BalanceDurationRelative
"call options.relativeTo.calendar.dateAdd", // 11.b MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.b MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.e.iv MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.e.iv MoveRelativeDate
@ -248,7 +238,6 @@ assert.compareArray(actual, expectedOpsForDayToMonthBalancing, "order of operati
actual.splice(0); // clear actual.splice(0); // clear
const expectedOpsForDayToWeekBalancing = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForDayToWeekBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// BalanceDurationRelative // BalanceDurationRelative
"call options.relativeTo.calendar.dateAdd", // 12.c MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 12.c MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 12.f.iv MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 12.f.iv MoveRelativeDate
@ -360,14 +349,17 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
// basic order of operations with ZonedDateTime relativeTo: // basic order of operations with ZonedDateTime relativeTo:
instance.round(createOptionsObserver({ relativeTo: zonedRelativeTo })); instance.round(createOptionsObserver({ relativeTo: zonedRelativeTo }));
assert.compareArray(actual, expectedOpsForZonedRelativeTo, "order of operations for ZonedDateTime relativeTo"); assert.compareArray(actual, expectedOpsForZonedRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]), "order of operations for ZonedDateTime relativeTo");
actual.splice(0); // clear actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year with minimal calendar operations: // code path through RoundDuration that rounds to the nearest year with minimal calendar operations:
const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate // ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup // lookup in Duration.p.round
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// NanosecondsToDays // NanosecondsToDays
@ -395,7 +387,7 @@ actual.splice(0); // clear
const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate // ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup // lookup in Duration.p.round
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// MoveRelativeZonedDateTime → AddZonedDateTime // MoveRelativeZonedDateTime → AddZonedDateTime
@ -432,8 +424,9 @@ actual.splice(0); // clear
const expectedOpsForUnbalanceRoundBalance = expectedOpsForZonedRelativeTo.concat([ const expectedOpsForUnbalanceRoundBalance = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate // ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup // lookup in Duration.p.round
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// No user code calls in UnbalanceDurationRelative // No user code calls in UnbalanceDurationRelative
// RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime // RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
"call options.relativeTo.calendar.dateAdd", "call options.relativeTo.calendar.dateAdd",

View File

@ -92,7 +92,6 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"has options.relativeTo.calendar.year", "has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields", "has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek", "has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields", "get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields", "get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields", "call options.relativeTo.calendar.fields",
@ -119,7 +118,7 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"call options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields // InterpretTemporalDateTimeFields
"call options.relativeTo.calendar.dateFromFields", "call options.relativeTo.calendar.dateFromFields",
// lookup 2 // lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// AddDuration // AddDuration
@ -231,6 +230,9 @@ const expectedOpsForPlainRelativeToNoCalendarOperations = [
"call options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields // InterpretTemporalDateTimeFields
"call options.relativeTo.calendar.dateFromFields", "call options.relativeTo.calendar.dateFromFields",
// lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]; ];
const noCalendarInstance = new Temporal.Duration(0, 0, 0, 4, 5, 6, 7, 987, 654, 321); const noCalendarInstance = new Temporal.Duration(0, 0, 0, 4, 5, 6, 7, 987, 654, 321);
@ -273,7 +275,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"has options.relativeTo.calendar.year", "has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields", "has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek", "has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields", "get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields", "get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields", "call options.relativeTo.calendar.fields",
@ -323,7 +324,7 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.timeZone.getPossibleInstantsFor", "get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor", "call options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup 2 // lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// AddDuration // AddDuration
@ -419,7 +420,6 @@ const expectedOpsForZonedRelativeToNoDaysOperations = [
"has options.relativeTo.calendar.year", "has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields", "has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek", "has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields", "get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields", "get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields", "call options.relativeTo.calendar.fields",
@ -469,6 +469,9 @@ const expectedOpsForZonedRelativeToNoDaysOperations = [
"get options.relativeTo.timeZone.getPossibleInstantsFor", "get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor", "call options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup in AddDurationToOrSubtractDurationFromDuration
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]; ];
const noDaysInstance = new Temporal.Duration(0, 0, 0, 0, 5, 6, 7, 987, 654, 321); const noDaysInstance = new Temporal.Duration(0, 0, 0, 0, 5, 6, 7, 987, 654, 321);

View File

@ -85,6 +85,9 @@ const expectedOpsForPlainRelativeTo = [
"get options.unit", "get options.unit",
"get options.unit.toString", "get options.unit.toString",
"call options.unit.toString", "call options.unit.toString",
// lookup in Duration.p.total
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]; ];
const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
@ -102,9 +105,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year with minimal calendar calls: // code path through RoundDuration that rounds to the nearest year with minimal calendar calls:
const expectedOpsForMinimalYearRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForMinimalYearRounding = expectedOpsForPlainRelativeTo.concat([
// lookup
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// 7.e and 7.g not called because years, months, weeks are 0 // 7.e and 7.g not called because years, months, weeks are 0
"call options.relativeTo.calendar.dateUntil", // 7.o "call options.relativeTo.calendar.dateUntil", // 7.o
// 7.s not called because years, months, weeks are 0 // 7.s not called because years, months, weeks are 0
@ -116,8 +116,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year: // code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateAdd", // 7.d "call options.relativeTo.calendar.dateAdd", // 7.d
"call options.relativeTo.calendar.dateAdd", // 7.f "call options.relativeTo.calendar.dateAdd", // 7.f
"call options.relativeTo.calendar.dateUntil", // 7.n "call options.relativeTo.calendar.dateUntil", // 7.n
@ -131,8 +129,6 @@ actual.splice(0); // clear
// code path through Duration.prototype.total that rounds to the nearest month: // code path through Duration.prototype.total that rounds to the nearest month:
const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// UnbalanceDurationRelative // UnbalanceDurationRelative
"call options.relativeTo.calendar.dateAdd", // 9.d.i "call options.relativeTo.calendar.dateAdd", // 9.d.i
"call options.relativeTo.calendar.dateUntil", // 9.d.iv "call options.relativeTo.calendar.dateUntil", // 9.d.iv
@ -148,7 +144,6 @@ actual.splice(0); // clear
// code path through Duration.prototype.total that rounds to the nearest week: // code path through Duration.prototype.total that rounds to the nearest week:
const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// UnbalanceDurationRelative // UnbalanceDurationRelative
"call options.relativeTo.calendar.dateAdd", // 10.c.i MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 10.c.i MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.d.i MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 10.d.i MoveRelativeDate
@ -162,7 +157,6 @@ actual.splice(0); // clear
// code path through UnbalanceDurationRelative that rounds to the nearest day: // code path through UnbalanceDurationRelative that rounds to the nearest day:
const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([ const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd", // 11.a.iii.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.iii.1 MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.a.iv.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.iv.1 MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.a.v.1 MoveRelativeDate "call options.relativeTo.calendar.dateAdd", // 11.a.v.1 MoveRelativeDate
@ -267,14 +261,18 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
// basic order of observable operations, without rounding: // basic order of observable operations, without rounding:
instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: zonedRelativeTo })); instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: zonedRelativeTo }));
assert.compareArray(actual, expectedOpsForZonedRelativeTo, "order of operations for ZonedDateTime relativeTo"); assert.compareArray(actual, expectedOpsForZonedRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
]), "order of operations for ZonedDateTime relativeTo");
actual.splice(0); // clear actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year with minimal calendar operations: // code path through RoundDuration that rounds to the nearest year with minimal calendar operations:
const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate // ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
"get options.relativeTo.calendar.dateAdd", // lookup // lookup in Duration.p.total
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// BalancePossiblyInfiniteDuration → NanosecondsToDays // BalancePossiblyInfiniteDuration → NanosecondsToDays
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 7. GetPlainDateTimeFor "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 7. GetPlainDateTimeFor
@ -304,7 +302,7 @@ actual.splice(0); // clear
const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate // ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup // lookup in Duration.p.total
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil", "get options.relativeTo.calendar.dateUntil",
// MoveRelativeZonedDateTime → AddZonedDateTime // MoveRelativeZonedDateTime → AddZonedDateTime
@ -339,8 +337,9 @@ actual.splice(0); // clear
const expectedOpsForUnbalanceRound = expectedOpsForZonedRelativeTo.concat([ const expectedOpsForUnbalanceRound = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate // ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup // lookup in Duration.p.total
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// No user code calls in UnbalanceDateDurationRelative // No user code calls in UnbalanceDateDurationRelative
// MoveRelativeZonedDateTime → AddZonedDateTime // MoveRelativeZonedDateTime → AddZonedDateTime
"call options.relativeTo.calendar.dateAdd", "call options.relativeTo.calendar.dateAdd",
@ -365,8 +364,9 @@ actual.splice(0); // clear
const expectedOpsForBalanceRound = expectedOpsForZonedRelativeTo.concat([ const expectedOpsForBalanceRound = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate // ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup // lookup in Duration.p.total
"get options.relativeTo.calendar.dateAdd", "get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// No user code calls in UnbalanceDateDurationRelative // No user code calls in UnbalanceDateDurationRelative
// No user code calls in AddZonedDateTime (years, months, weeks = 0) // No user code calls in AddZonedDateTime (years, months, weeks = 0)
// BalanceTimeDurationRelative // BalanceTimeDurationRelative

View File

@ -103,6 +103,7 @@ const noCalendarExpected = [
"call fields.seconds.valueOf", "call fields.seconds.valueOf",
"get fields.weeks", "get fields.weeks",
"get fields.years", "get fields.years",
"get this.calendar.dateAdd",
// AddDate // AddDate
"get options.overflow", "get options.overflow",
"get options.overflow.toString", "get options.overflow.toString",

View File

@ -105,6 +105,7 @@ actual.splice(0);
instance.since(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" })); instance.since(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected.concat([ assert.compareArray(actual, expected.concat([
// lookup // lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil", "get this.calendar.dateUntil",
// CalendarDateUntil // CalendarDateUntil
"call this.calendar.dateUntil", "call this.calendar.dateUntil",

View File

@ -103,6 +103,7 @@ const noCalendarExpected = [
"call fields.seconds.valueOf", "call fields.seconds.valueOf",
"get fields.weeks", "get fields.weeks",
"get fields.years", "get fields.years",
"get this.calendar.dateAdd",
// AddDate // AddDate
"get options.overflow", "get options.overflow",
"get options.overflow.toString", "get options.overflow.toString",

View File

@ -105,6 +105,7 @@ actual.splice(0);
instance.until(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" })); instance.until(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected.concat([ assert.compareArray(actual, expected.concat([
// lookup // lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil", "get this.calendar.dateUntil",
// CalendarDateUntil // CalendarDateUntil
"call this.calendar.dateUntil", "call this.calendar.dateUntil",

View File

@ -101,6 +101,7 @@ const noCalendarExpected = [
"call fields.seconds.valueOf", "call fields.seconds.valueOf",
"get fields.weeks", "get fields.weeks",
"get fields.years", "get fields.years",
"get this.calendar.dateAdd",
// AddDateTime -> AddDate // AddDateTime -> AddDate
"get options.overflow", "get options.overflow",
"get options.overflow.toString", "get options.overflow.toString",

View File

@ -129,6 +129,7 @@ actual.splice(0);
instance.since(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" })); instance.since(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected.concat([ assert.compareArray(actual, expected.concat([
// lookup // lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil", "get this.calendar.dateUntil",
// CalendarDateUntil // CalendarDateUntil
"call this.calendar.dateUntil", "call this.calendar.dateUntil",

View File

@ -101,6 +101,7 @@ const noCalendarExpected = [
"call fields.seconds.valueOf", "call fields.seconds.valueOf",
"get fields.weeks", "get fields.weeks",
"get fields.years", "get fields.years",
"get this.calendar.dateAdd",
// AddDateTime -> AddDate // AddDateTime -> AddDate
"get options.overflow", "get options.overflow",
"get options.overflow.toString", "get options.overflow.toString",

View File

@ -129,6 +129,7 @@ actual.splice(0);
instance.until(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" })); instance.until(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected.concat([ assert.compareArray(actual, expected.concat([
// lookup // lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil", "get this.calendar.dateUntil",
// CalendarDateUntil // CalendarDateUntil
"call this.calendar.dateUntil", "call this.calendar.dateUntil",

View File

@ -43,6 +43,7 @@ const expected = [
// lookup // lookup
"get this.calendar.dateAdd", "get this.calendar.dateAdd",
"get this.calendar.dateFromFields", "get this.calendar.dateFromFields",
"get this.calendar.day",
"get this.calendar.fields", "get this.calendar.fields",
"get this.calendar.yearMonthFromFields", "get this.calendar.yearMonthFromFields",
// CalendarFields // CalendarFields
@ -129,7 +130,9 @@ const noCalendarExpected = [
"get fields.weeks", "get fields.weeks",
"get fields.years", "get fields.years",
// lookup // lookup
"get this.calendar.dateAdd",
"get this.calendar.dateFromFields", "get this.calendar.dateFromFields",
"get this.calendar.day",
"get this.calendar.fields", "get this.calendar.fields",
"get this.calendar.yearMonthFromFields", "get this.calendar.yearMonthFromFields",
// CalendarFields // CalendarFields

View File

@ -123,28 +123,7 @@ actual.splice(0);
// code path that skips RoundDuration: // code path that skips RoundDuration:
instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 })); instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 }));
assert.compareArray(actual, expectedMinimal.concat([ assert.compareArray(actual, expected, "order of operations with no rounding");
// lookup
"get this.calendar.dateFromFields",
"get this.calendar.dateUntil",
"get this.calendar.fields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields / CalendarDateFromFields (receiver)
"get this.calendar.monthCode",
"call this.calendar.monthCode",
"get this.calendar.year",
"call this.calendar.year",
"call this.calendar.dateFromFields",
// PrepareTemporalFields / CalendarDateFromFields (argument)
"get other.calendar.monthCode",
"call other.calendar.monthCode",
"get other.calendar.year",
"call other.calendar.year",
"call this.calendar.dateFromFields",
// CalendarDateUntil
"call this.calendar.dateUntil",
]), "order of operations with no rounding");
actual.splice(0); // clear actual.splice(0); // clear
// short-circuit for identical objects: // short-circuit for identical objects:

View File

@ -123,28 +123,7 @@ actual.splice(0);
// code path that skips RoundDuration: // code path that skips RoundDuration:
instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 })); instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 }));
assert.compareArray(actual, expectedMinimal.concat([ assert.compareArray(actual, expected, "order of operations with no rounding");
// lookup
"get this.calendar.dateFromFields",
"get this.calendar.dateUntil",
"get this.calendar.fields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields / CalendarDateFromFields (receiver)
"get this.calendar.monthCode",
"call this.calendar.monthCode",
"get this.calendar.year",
"call this.calendar.year",
"call this.calendar.dateFromFields",
// PrepareTemporalFields / CalendarDateFromFields (argument)
"get other.calendar.monthCode",
"call other.calendar.monthCode",
"get other.calendar.year",
"call other.calendar.year",
"call this.calendar.dateFromFields",
// CalendarDateUntil
"call this.calendar.dateUntil",
]), "order of operations with no rounding");
actual.splice(0); // clear actual.splice(0); // clear
// short-circuit for identical objects: // short-circuit for identical objects:

View File

@ -42,7 +42,7 @@ const expected = [
"has calendar.year", "has calendar.year",
"has calendar.yearMonthFromFields", "has calendar.yearMonthFromFields",
"has calendar.yearOfWeek", "has calendar.yearOfWeek",
// lookup // lookup in ToTemporalZonedDateTime
"get calendar.dateFromFields", "get calendar.dateFromFields",
"get calendar.fields", "get calendar.fields",
// CalendarFields // CalendarFields

View File

@ -48,7 +48,7 @@ const expected = [
"has calendar.year", "has calendar.year",
"has calendar.yearMonthFromFields", "has calendar.yearMonthFromFields",
"has calendar.yearOfWeek", "has calendar.yearOfWeek",
// lookup // lookup in ToTemporalZonedDateTime
"get calendar.dateFromFields", "get calendar.dateFromFields",
"get calendar.fields", "get calendar.fields",
// CalendarFields // CalendarFields

View File

@ -48,7 +48,7 @@ const expected = [
"has calendar.year", "has calendar.year",
"has calendar.yearMonthFromFields", "has calendar.yearMonthFromFields",
"has calendar.yearOfWeek", "has calendar.yearOfWeek",
// lookup // lookup in ToTemporalZonedDateTime
"get calendar.dateFromFields", "get calendar.dateFromFields",
"get calendar.fields", "get calendar.fields",
// CalendarFields // CalendarFields

View File

@ -48,7 +48,7 @@ const expected = [
"has calendar.year", "has calendar.year",
"has calendar.yearMonthFromFields", "has calendar.yearMonthFromFields",
"has calendar.yearOfWeek", "has calendar.yearOfWeek",
// lookup // lookup in ToTemporalZonedDateTime
"get calendar.dateFromFields", "get calendar.dateFromFields",
"get calendar.fields", "get calendar.fields",
// CalendarFields // CalendarFields