Temporal: Look up calendar methods only once

This commit is contained in:
Philip Chimento 2023-03-11 12:46:51 -08:00 committed by Philip Chimento
parent 911fe9612e
commit c5dd01f7c0
46 changed files with 479 additions and 264 deletions

View File

@ -32,8 +32,10 @@ const expected = [
"has date.calendar.year",
"has date.calendar.yearMonthFromFields",
"has date.calendar.yearOfWeek",
// ToTemporalDate → CalendarFields
// lookup
"get date.calendar.dateFromFields",
"get date.calendar.fields",
// ToTemporalDate → CalendarFields
"call date.calendar.fields",
// ToTemporalDate → PrepareTemporalFields
"get date.day",
@ -49,7 +51,6 @@ const expected = [
"get date.year.valueOf",
"call date.year.valueOf",
// ToTemporalDate → CalendarDateFromFields
"get date.calendar.dateFromFields",
"call date.calendar.dateFromFields",
// ToTemporalDuration
"get duration.days",

View File

@ -32,8 +32,10 @@ const expected = [
"has one.calendar.year",
"has one.calendar.yearMonthFromFields",
"has one.calendar.yearOfWeek",
// ToTemporalDate 1 → CalendarFields
// lookup
"get one.calendar.dateFromFields",
"get one.calendar.fields",
// ToTemporalDate 1 → CalendarFields
"call one.calendar.fields",
// ToTemporalDate 1 → PrepareTemporalFields
"get one.day",
@ -49,7 +51,6 @@ const expected = [
"get one.year.valueOf",
"call one.year.valueOf",
// ToTemporalDate 1 → CalendarDateFromFields
"get one.calendar.dateFromFields",
"call one.calendar.dateFromFields",
// ToTemporalDate 2 → GetTemporalCalendarSlotValueWithISODefault
"get two.calendar",
@ -74,8 +75,10 @@ const expected = [
"has two.calendar.year",
"has two.calendar.yearMonthFromFields",
"has two.calendar.yearOfWeek",
// ToTemporalDate 2 → CalendarFields
// lookup
"get two.calendar.dateFromFields",
"get two.calendar.fields",
// ToTemporalDate 2 → CalendarFields
"call two.calendar.fields",
// ToTemporalDate 2 → PrepareTemporalFields
"get two.day",
@ -91,7 +94,6 @@ const expected = [
"get two.year.valueOf",
"call two.year.valueOf",
// ToTemporalDate 2 → CalendarDateFromFields
"get two.calendar.dateFromFields",
"call two.calendar.dateFromFields",
// GetTemporalUnit
"get options.largestUnit",

View File

@ -109,6 +109,8 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
"get options.relativeTo.day",
@ -131,7 +133,6 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"get options.relativeTo.year",
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
]);
@ -175,13 +176,12 @@ actual.splice(0); // clear
// to days:
const expectedOpsForPlainDayBalancing = expectedOpsForPlainRelativeTo.concat(
[
"get options.relativeTo.calendar.dateAdd",
// UnbalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 11.a.ii
"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.v.1 MoveRelativeDate
// UnbalanceDurationRelative again for the second argument:
"get options.relativeTo.calendar.dateAdd", // 11.a.ii
"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.v.1 MoveRelativeDate
@ -219,6 +219,7 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
"get options.relativeTo.day",
@ -255,7 +256,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.year",
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
"has options.relativeTo.timeZone.getPossibleInstantsFor",
@ -323,13 +323,12 @@ Temporal.Duration.compare(
assert.compareArray(
actual,
expectedOpsForZonedRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// AddZonedDateTime on first argument
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// AddZonedDateTime on second argument
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
]),

View File

@ -48,11 +48,12 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",

View File

@ -92,6 +92,8 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
// PrepareTemporalFields
@ -116,13 +118,13 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
// AddDuration
// lookup 2
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// AddDuration
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateUntil",
]);
@ -203,6 +205,7 @@ const expectedOpsForPlainRelativeToNoCalendarOperations = [
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
// PrepareTemporalFields
@ -227,7 +230,6 @@ const expectedOpsForPlainRelativeToNoCalendarOperations = [
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
];
@ -271,6 +273,8 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
// PrepareTemporalFields
@ -309,7 +313,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
// ToRelativeTemporalObject again
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
@ -320,24 +323,23 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup 2
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// AddDuration
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// AddDuration → AddZonedDateTime 1
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// AddDuration → AddZonedDateTime 2
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// AddDuration → DifferenceZonedDateTime
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// AddDuration → DifferenceZonedDateTime → DifferenceISODateTime
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateUntil",
// AddDuration → DifferenceZonedDateTime → AddZonedDateTime
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// AddDuration → DifferenceZonedDateTime → NanosecondsToDays

View File

@ -47,11 +47,12 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",

View File

@ -69,6 +69,7 @@ const expectedOpsForPlainRelativeTo = [
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
"get options.relativeTo.day",
@ -91,7 +92,6 @@ const expectedOpsForPlainRelativeTo = [
"get options.relativeTo.year",
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
"get options.roundingIncrement",
"get options.roundingIncrement.valueOf",
@ -119,9 +119,9 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year, with minimal calendar calls:
const expectedMinimalOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd", // 7.c
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// 7.e and 7.g not called because years, months, weeks are 0
"get options.relativeTo.calendar.dateUntil", // 7.o
"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
@ -132,19 +132,17 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd", // 7.c
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateAdd", // 7.e
"call options.relativeTo.calendar.dateAdd", // 7.g
"get options.relativeTo.calendar.dateUntil", // 7.o
"call options.relativeTo.calendar.dateUntil", // 7.o
"call options.relativeTo.calendar.dateAdd", // 7.s MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate
// BalanceDateDurationRelative
"get options.relativeTo.calendar.dateAdd", // 11.a.i
"call options.relativeTo.calendar.dateAdd", // 11.c MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.g MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.k
"get options.relativeTo.calendar.dateUntil", // 11.l.i
"call options.relativeTo.calendar.dateUntil", // 11.p
]);
const instanceYears = new Temporal.Duration(1, 12, 0, 0, /* hours = */ 2400);
@ -154,19 +152,17 @@ actual.splice(0); // clear
// code path through Duration.prototype.round that rounds to the nearest month:
const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// UnbalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 9.b
"get options.relativeTo.calendar.dateUntil", // 9.c
"call options.relativeTo.calendar.dateAdd", // 9.d.i
"call options.relativeTo.calendar.dateUntil", // 9.d.iv
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 10.b
"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
// BalanceDurationRelative
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
]);
const instance2 = new Temporal.Duration(1, 0, 0, 62);
@ -176,16 +172,14 @@ actual.splice(0); // clear
// code path through Duration.prototype.round that rounds to the nearest week:
const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// UnbalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 10.b
"call options.relativeTo.calendar.dateAdd", // 10.c.i MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.d.i MoveRelativeDate
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 11.c
"call options.relativeTo.calendar.dateAdd", // 11.d MoveRelativeDate
], Array(58).fill("call options.relativeTo.calendar.dateAdd"), [ // 58× 11.g.iii MoveRelativeDate (52 + 4 + 2)
// BalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 12.b
"call options.relativeTo.calendar.dateAdd", // 12.c
]);
const instance3 = new Temporal.Duration(1, 1, 0, 15);
@ -195,7 +189,7 @@ actual.splice(0); // clear
// code path through UnbalanceDurationRelative that rounds to the nearest day:
const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd", // 11.a.ii
"get options.relativeTo.calendar.dateAdd",
"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.v.1 MoveRelativeDate
@ -207,13 +201,13 @@ actual.splice(0); // clear
// code path through BalanceDurationRelative balancing from days up to years:
const expectedOpsForDayToYearBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd", // 10.a
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateAdd", // 10.b MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.e.iv MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.f MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.i.iv MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.j
"get options.relativeTo.calendar.dateUntil", // 10.k
"call options.relativeTo.calendar.dateUntil", // 10.n
]);
const instance5 = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 396 * 24);
@ -223,17 +217,16 @@ actual.splice(0); // clear
// code path through Duration.prototype.round balancing from months up to years:
const expectedOpsForMonthToYearBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 10.b
"call options.relativeTo.calendar.dateAdd", // 10.c
"call options.relativeTo.calendar.dateAdd", // 10.e
"call options.relativeTo.calendar.dateAdd", // 10.k MoveRelativeDate
// BalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 10.a
"call options.relativeTo.calendar.dateAdd", // 10.b MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.f MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.j
"get options.relativeTo.calendar.dateUntil", // 10.k
"call options.relativeTo.calendar.dateUntil", // 10.n
"call options.relativeTo.calendar.dateAdd", // 10.p.iv
"call options.relativeTo.calendar.dateUntil", // 10.p.vii
@ -244,8 +237,8 @@ assert.compareArray(actual, expectedOpsForMonthToYearBalancing, "order of operat
actual.splice(0); // clear
const expectedOpsForDayToMonthBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// BalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 11.a
"call options.relativeTo.calendar.dateAdd", // 11.b MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.e.iv MoveRelativeDate
]);
@ -255,8 +248,8 @@ assert.compareArray(actual, expectedOpsForDayToMonthBalancing, "order of operati
actual.splice(0); // clear
const expectedOpsForDayToWeekBalancing = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// BalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 12.b
"call options.relativeTo.calendar.dateAdd", // 12.c MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 12.f.iv MoveRelativeDate
]);
@ -292,6 +285,7 @@ const expectedOpsForZonedRelativeTo = [
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
"get options.relativeTo.day",
@ -328,7 +322,6 @@ const expectedOpsForZonedRelativeTo = [
"get options.relativeTo.year",
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
"has options.relativeTo.timeZone.getPossibleInstantsFor",
@ -374,6 +367,9 @@ actual.splice(0); // clear
const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// NanosecondsToDays
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 7. GetPlainDateTimeFor
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 11. GetPlainDateTimeFor
@ -382,9 +378,7 @@ const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.con
// NanosecondsToDays → AddDaysToZonedDateTime
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 7.c
// 7.e and 7.g not called because years, months, weeks are 0
"get options.relativeTo.calendar.dateUntil", // 7.o
"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
@ -401,8 +395,10 @@ actual.splice(0); // clear
const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// MoveRelativeZonedDateTime → AddZonedDateTime
// lookup
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// MoveRelativeZonedDateTime → AddZonedDateTime
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// NanosecondsToDays
@ -412,19 +408,15 @@ const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// NanosecondsToDays → AddDaysToZonedDateTime
"call options.relativeTo.timeZone.getPossibleInstantsFor",
"get options.relativeTo.calendar.dateAdd", // 7.c
"call options.relativeTo.calendar.dateAdd", // 7.e
"call options.relativeTo.calendar.dateAdd", // 7.g
"get options.relativeTo.calendar.dateUntil", // 7.o
"call options.relativeTo.calendar.dateUntil", // 7.o
"call options.relativeTo.calendar.dateAdd", // 7.s MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate
// BalanceDateDurationRelative
"get options.relativeTo.calendar.dateAdd", // 11.a.i
"call options.relativeTo.calendar.dateAdd", // 11.c MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.g MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 11.k
"get options.relativeTo.calendar.dateUntil", // 11.l.i
"call options.relativeTo.calendar.dateUntil", // 11.p
]);
instanceYears.round(createOptionsObserver({ smallestUnit: "years", relativeTo: zonedRelativeTo }));
@ -440,16 +432,15 @@ actual.splice(0); // clear
const expectedOpsForUnbalanceRoundBalance = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup
"get options.relativeTo.calendar.dateAdd",
// No user code calls in UnbalanceDurationRelative
// RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
"get options.relativeTo.calendar.dateAdd", // 11.
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 8.e.i
"call options.relativeTo.calendar.dateAdd", // 8.g MoveRelativeDate
// BalanceDateDurationRelative
"get options.relativeTo.calendar.dateAdd", // 13.a.i
"call options.relativeTo.calendar.dateAdd", // 13.c MoveRelativeDate
]);
new Temporal.Duration(0, 1, 1).round(createOptionsObserver({ largestUnit: "months", smallestUnit: "weeks", relativeTo: zonedRelativeTo }));

View File

@ -47,11 +47,12 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",

View File

@ -92,6 +92,8 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
// PrepareTemporalFields
@ -116,13 +118,13 @@ const expectedOpsForPlainRelativeTo = expected.concat([
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
// AddDuration
// lookup 2
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// AddDuration
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateUntil",
]);
@ -203,6 +205,7 @@ const expectedOpsForPlainRelativeToNoCalendarOperations = [
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
// PrepareTemporalFields
@ -227,7 +230,6 @@ const expectedOpsForPlainRelativeToNoCalendarOperations = [
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
];
@ -271,6 +273,8 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
// lookup
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
// PrepareTemporalFields
@ -309,7 +313,6 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
// ToRelativeTemporalObject again
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
@ -320,24 +323,23 @@ const expectedOpsForZonedRelativeTo = expected.concat([
"get options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup 2
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// AddDuration
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// AddDuration → AddZonedDateTime 1
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// AddDuration → AddZonedDateTime 2
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// AddDuration → DifferenceZonedDateTime
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// AddDuration → DifferenceZonedDateTime → DifferenceISODateTime
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateUntil",
// AddDuration → DifferenceZonedDateTime → AddZonedDateTime
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// AddDuration → DifferenceZonedDateTime → NanosecondsToDays

View File

@ -47,11 +47,12 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",

View File

@ -57,6 +57,7 @@ const expectedOpsForPlainRelativeTo = [
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
"get options.relativeTo.day",
@ -79,7 +80,6 @@ const expectedOpsForPlainRelativeTo = [
"get options.relativeTo.year",
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
// GetTemporalUnit
"get options.unit",
@ -102,9 +102,10 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year with minimal calendar calls:
const expectedOpsForMinimalYearRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd", // 7.c
// lookup
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// 7.e and 7.g not called because years, months, weeks are 0
"get options.relativeTo.calendar.dateUntil", // 7.o
"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
@ -115,10 +116,10 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd", // 7.c
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
"call options.relativeTo.calendar.dateAdd", // 7.d
"call options.relativeTo.calendar.dateAdd", // 7.f
"get options.relativeTo.calendar.dateUntil", // 7.n
"call options.relativeTo.calendar.dateUntil", // 7.n
"call options.relativeTo.calendar.dateAdd", // 7.s
"call options.relativeTo.calendar.dateAdd", // 7.x MoveRelativeDate
@ -130,13 +131,12 @@ actual.splice(0); // clear
// code path through Duration.prototype.total that rounds to the nearest month:
const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// UnbalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 9.b
"get options.relativeTo.calendar.dateUntil", // 9.c
"call options.relativeTo.calendar.dateAdd", // 9.d.i
"call options.relativeTo.calendar.dateUntil", // 9.d.iv
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 10.b
"call options.relativeTo.calendar.dateAdd", // 10.c
"call options.relativeTo.calendar.dateAdd", // 10.e
"call options.relativeTo.calendar.dateAdd", // 10.k MoveRelativeDate
@ -148,12 +148,11 @@ actual.splice(0); // clear
// code path through Duration.prototype.total that rounds to the nearest week:
const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd",
// UnbalanceDurationRelative
"get options.relativeTo.calendar.dateAdd", // 10.b
"call options.relativeTo.calendar.dateAdd", // 10.c.i MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 10.d.i MoveRelativeDate
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 11.c
"call options.relativeTo.calendar.dateAdd", // 11.d MoveRelativeDate
], Array(58).fill("call options.relativeTo.calendar.dateAdd")); // 58× 11.g.iii MoveRelativeDate (52 + 4 + 2)
const instance3 = new Temporal.Duration(1, 1, 0, 15);
@ -163,7 +162,7 @@ actual.splice(0); // clear
// code path through UnbalanceDurationRelative that rounds to the nearest day:
const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([
"get options.relativeTo.calendar.dateAdd", // 11.a.ii
"get options.relativeTo.calendar.dateAdd",
"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.v.1 MoveRelativeDate
@ -198,6 +197,7 @@ const expectedOpsForZonedRelativeTo = [
"has options.relativeTo.calendar.year",
"has options.relativeTo.calendar.yearMonthFromFields",
"has options.relativeTo.calendar.yearOfWeek",
"get options.relativeTo.calendar.dateFromFields",
"get options.relativeTo.calendar.fields",
"call options.relativeTo.calendar.fields",
"get options.relativeTo.day",
@ -234,7 +234,6 @@ const expectedOpsForZonedRelativeTo = [
"get options.relativeTo.year",
"get options.relativeTo.year.valueOf",
"call options.relativeTo.year.valueOf",
"get options.relativeTo.calendar.dateFromFields",
"call options.relativeTo.calendar.dateFromFields",
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
"has options.relativeTo.timeZone.getPossibleInstantsFor",
@ -275,6 +274,8 @@ actual.splice(0); // clear
const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
"get options.relativeTo.calendar.dateAdd", // lookup
"get options.relativeTo.calendar.dateUntil",
// BalancePossiblyInfiniteDuration → NanosecondsToDays
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 7. GetPlainDateTimeFor
"call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 11. GetPlainDateTimeFor
@ -286,9 +287,7 @@ const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.con
// code path through RoundDuration that rounds to the nearest year:
// MoveRelativeZonedDateTime → AddDaysToZonedDateTime
"call options.relativeTo.timeZone.getPossibleInstantsFor",
"get options.relativeTo.calendar.dateAdd", // 7.c
// 7.e and 7.g not called because years, months, weeks are 0
"get options.relativeTo.calendar.dateUntil", // 7.o
"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
@ -305,8 +304,10 @@ actual.splice(0); // clear
const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// MoveRelativeZonedDateTime → AddZonedDateTime
// lookup
"get options.relativeTo.calendar.dateAdd",
"get options.relativeTo.calendar.dateUntil",
// MoveRelativeZonedDateTime → AddZonedDateTime
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// BalancePossiblyInfiniteTimeDurationRelative → NanosecondsToDays
@ -317,14 +318,11 @@ const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([
// BalancePossiblyInfiniteTimeDurationRelative → NanosecondsToDays → AddDaysToZonedDateTime
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
"get options.relativeTo.calendar.dateAdd",
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor",
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 7.c
"call options.relativeTo.calendar.dateAdd", // 7.e
"call options.relativeTo.calendar.dateAdd", // 7.g
"get options.relativeTo.calendar.dateUntil", // 7.o
"call options.relativeTo.calendar.dateUntil", // 7.o
"call options.relativeTo.calendar.dateAdd", // 7.s MoveRelativeDate
"call options.relativeTo.calendar.dateAdd", // 7.y MoveRelativeDate
@ -341,17 +339,16 @@ actual.splice(0); // clear
const expectedOpsForUnbalanceRound = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup
"get options.relativeTo.calendar.dateAdd",
// No user code calls in UnbalanceDateDurationRelative
// MoveRelativeZonedDateTime → AddZonedDateTime
"get options.relativeTo.calendar.dateAdd", // 11.
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor
// RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
"get options.relativeTo.calendar.dateAdd", // 11.
"call options.relativeTo.calendar.dateAdd",
"call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 7.d.i
"call options.relativeTo.calendar.dateAdd", // 7.f
"call options.relativeTo.calendar.dateAdd", // 7.h
"call options.relativeTo.calendar.dateAdd", // 7.n MoveRelativeDate
@ -368,6 +365,8 @@ actual.splice(0); // clear
const expectedOpsForBalanceRound = expectedOpsForZonedRelativeTo.concat([
// ToTemporalDate
"call options.relativeTo.timeZone.getOffsetNanosecondsFor",
// lookup
"get options.relativeTo.calendar.dateAdd",
// No user code calls in UnbalanceDateDurationRelative
// No user code calls in AddZonedDateTime (years, months, weeks = 0)
// BalanceTimeDurationRelative
@ -379,7 +378,6 @@ const expectedOpsForBalanceRound = expectedOpsForZonedRelativeTo.concat([
// RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
"call options.relativeTo.timeZone.getPossibleInstantsFor", // 10. GetInstantFor
// RoundDuration
"get options.relativeTo.calendar.dateAdd", // 10.d.i
"call options.relativeTo.calendar.dateAdd", // 10.f
"call options.relativeTo.calendar.dateAdd", // 10.i.iii
]);

View File

@ -47,11 +47,12 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",

View File

@ -36,6 +36,7 @@ const expected = [
"has fields.calendar.year",
"has fields.calendar.yearMonthFromFields",
"has fields.calendar.yearOfWeek",
"get fields.calendar.dateFromFields",
"get fields.calendar.fields",
"call fields.calendar.fields",
"get fields.day",
@ -50,7 +51,6 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
"get fields.calendar.dateFromFields",
"call fields.calendar.dateFromFields",
// inside Calendar.p.dateFromFields
"get options.overflow.toString",

View File

@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expectedMinimal = [
const expected = [
// ToTemporalDate
"get other.calendar",
"has other.calendar.dateAdd",
@ -32,6 +32,7 @@ const expectedMinimal = [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -46,7 +47,6 @@ const expectedMinimal = [
"get other.year",
"get other.year.valueOf",
"call other.year.valueOf",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
// CalendarEquals
"get this.calendar.id",
@ -73,12 +73,6 @@ const expectedMinimal = [
"get options.smallestUnit.toString",
"call options.smallestUnit.toString",
];
const expected = expectedMinimal.concat([
// CalendarDateUntil
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
]);
const actual = [];
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
@ -109,7 +103,12 @@ actual.splice(0);
// basic order of observable operations with calendar call, without rounding:
instance.since(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected, "order of operations");
assert.compareArray(actual, expected.concat([
// lookup
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
]), "order of operations");
actual.splice(0); // clear
// short-circuit for identical objects:
@ -122,15 +121,19 @@ const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, {
}, "other");
instance.since(identicalPropertyBag, createOptionsObserver());
assert.compareArray(actual, expectedMinimal, "order of operations with identical dates");
assert.compareArray(actual, expected, "order of operations with identical dates");
actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -147,7 +150,12 @@ const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
}, "other");
const expectedOpsForYearRoundingSameMonth = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -158,7 +166,12 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat([
"get this.calendar.dateAdd", // 10.b
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -169,8 +182,13 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest week:
const expectedOpsForWeekRounding = expected.concat([
"get this.calendar.dateAdd", // 11.c
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 11.d MoveRelativeDate
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks");

View File

@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expectedMinimal = [
const expected = [
// ToTemporalDate
"get other.calendar",
"has other.calendar.dateAdd",
@ -32,6 +32,7 @@ const expectedMinimal = [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -46,7 +47,6 @@ const expectedMinimal = [
"get other.year",
"get other.year.valueOf",
"call other.year.valueOf",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
// CalendarEquals
"get this.calendar.id",
@ -73,12 +73,6 @@ const expectedMinimal = [
"get options.smallestUnit.toString",
"call options.smallestUnit.toString",
];
const expected = expectedMinimal.concat([
// CalendarDateUntil
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
]);
const actual = [];
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
@ -109,7 +103,12 @@ actual.splice(0);
// basic order of observable operations with calendar call, without rounding:
instance.until(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected, "order of operations");
assert.compareArray(actual, expected.concat([
// lookup
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
]), "order of operations");
actual.splice(0); // clear
// short-circuit for identical objects:
@ -123,15 +122,19 @@ const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, {
}, "other");
instance.since(identicalPropertyBag, createOptionsObserver());
assert.compareArray(actual, expectedMinimal, "order of operations with identical dates");
assert.compareArray(actual, expected, "order of operations with identical dates");
actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -148,7 +151,12 @@ const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
}, "other");
const expectedOpsForYearRoundingSameMonth = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -159,7 +167,12 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat([
"get this.calendar.dateAdd", // 10.b
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -170,8 +183,13 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest week:
const expectedOpsForWeekRounding = expected.concat([
"get this.calendar.dateAdd", // 11.c
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 11.d MoveRelativeDate
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks");

View File

@ -18,8 +18,11 @@ const expected = [
"get options.overflow",
"getOwnPropertyDescriptor options.extra",
"get options.extra",
// CalendarFields
// lookup
"get this.calendar.dateFromFields",
"get this.calendar.fields",
"get this.calendar.mergeFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.day",
@ -44,10 +47,8 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// CalendarMergeFields
"get this.calendar.mergeFields",
"call this.calendar.mergeFields",
// CalendarDateFromFields
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// inside Calendar.p.dateFromFields
"get options.overflow.toString",

View File

@ -38,8 +38,10 @@ const expected = [
"has fields.calendar.year",
"has fields.calendar.yearMonthFromFields",
"has fields.calendar.yearOfWeek",
// CalendarFields
// lookup
"get fields.calendar.dateFromFields",
"get fields.calendar.fields",
// CalendarFields
"call fields.calendar.fields",
// PrepareTemporalFields
"get fields.day",
@ -75,7 +77,6 @@ const expected = [
// InterpretTemporalDateTimeFields
"get options.overflow.toString",
"call options.overflow.toString",
"get fields.calendar.dateFromFields",
"call fields.calendar.dateFromFields",
];
const actual = [];

View File

@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expectedMinimal = [
const expected = [
// ToTemporalDateTime
"get other.calendar",
"has other.calendar.dateAdd",
@ -32,6 +32,7 @@ const expectedMinimal = [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -64,7 +65,6 @@ const expectedMinimal = [
"get other.year",
"get other.year.valueOf",
"call other.year.valueOf",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
// CalendarEquals
"get this.calendar.id",
@ -91,12 +91,6 @@ const expectedMinimal = [
"get options.smallestUnit.toString",
"call options.smallestUnit.toString",
];
const expected = expectedMinimal.concat([
// CalendarDateUntil
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
]);
const actual = [];
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
@ -133,7 +127,12 @@ actual.splice(0);
// basic order of observable operations with calendar call, without rounding:
instance.since(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected, "order of operations");
assert.compareArray(actual, expected.concat([
// lookup
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
]), "order of operations");
actual.splice(0); // clear
// short-circuit for identical objects:
@ -152,15 +151,19 @@ const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, {
}, "other");
instance.since(identicalPropertyBag, createOptionsObserver());
assert.compareArray(actual, expectedMinimal, "order of operations with identical datetimes");
assert.compareArray(actual, expected, "order of operations with identical datetimes");
actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -183,7 +186,12 @@ const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
}, "other");
const expectedOpsForYearRoundingSameMonth = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -194,7 +202,12 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat([
"get this.calendar.dateAdd", // 10.b
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -205,8 +218,13 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest week:
const expectedOpsForWeekRounding = expected.concat([
"get this.calendar.dateAdd", // 11.c
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 11.d MoveRelativeDate
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks");

View File

@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expectedMinimal = [
const expected = [
// ToTemporalDateTime
"get other.calendar",
"has other.calendar.dateAdd",
@ -32,6 +32,7 @@ const expectedMinimal = [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -64,7 +65,6 @@ const expectedMinimal = [
"get other.year",
"get other.year.valueOf",
"call other.year.valueOf",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
// CalendarEquals
"get this.calendar.id",
@ -91,12 +91,6 @@ const expectedMinimal = [
"get options.smallestUnit.toString",
"call options.smallestUnit.toString",
];
const expected = expectedMinimal.concat([
// CalendarDateUntil
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
]);
const actual = [];
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
@ -133,7 +127,12 @@ actual.splice(0);
// basic order of observable operations with calendar call, without rounding:
instance.until(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" }));
assert.compareArray(actual, expected, "order of operations");
assert.compareArray(actual, expected.concat([
// lookup
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
]), "order of operations");
actual.splice(0); // clear
// short-circuit for identical objects:
@ -152,15 +151,19 @@ const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, {
}, "other");
instance.until(identicalPropertyBag, createOptionsObserver());
assert.compareArray(actual, expectedMinimal, "order of operations with identical datetimes");
assert.compareArray(actual, expected, "order of operations with identical datetimes");
actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -183,7 +186,12 @@ const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
}, "other");
const expectedOpsForYearRoundingSameMonth = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -194,7 +202,12 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat([
"get this.calendar.dateAdd", // 10.b
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// 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
@ -205,8 +218,13 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest week:
const expectedOpsForWeekRounding = expected.concat([
"get this.calendar.dateAdd", // 11.c
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// CalendarDateUntil
"call this.calendar.dateUntil",
// RoundDuration
"call this.calendar.dateAdd", // 11.d MoveRelativeDate
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));
assert.compareArray(actual.slice(expected.length), expectedOpsForWeekRounding.slice(expected.length), "order of operations with smallestUnit = weeks");
assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks");

View File

@ -18,8 +18,11 @@ const expected = [
"get options.overflow",
"getOwnPropertyDescriptor options.extra",
"get options.extra",
// CalendarFields
// lookup
"get this.calendar.dateFromFields",
"get this.calendar.fields",
"get this.calendar.mergeFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.day",
@ -62,12 +65,10 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// CalendarMergeFields
"get this.calendar.mergeFields",
"call this.calendar.mergeFields",
// InterpretTemporalDateTimeFields
"get options.overflow.toString",
"call options.overflow.toString",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
];
const actual = [];

View File

@ -37,8 +37,10 @@ const expected = [
"has fields.calendar.year",
"has fields.calendar.yearMonthFromFields",
"has fields.calendar.yearOfWeek",
// CalendarFields
// lookup
"get fields.calendar.fields",
"get fields.calendar.monthDayFromFields",
// CalendarFields
"call fields.calendar.fields",
// PrepareTemporalFields
"get fields.day",
@ -54,7 +56,6 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// CalendarMonthDayFromFields
"get fields.calendar.monthDayFromFields",
"call fields.calendar.monthDayFromFields",
// inside Calendar.p.monthDayFromFields
"get options.overflow.toString",

View File

@ -18,8 +18,11 @@ const expected = [
"get options.overflow",
"getOwnPropertyDescriptor options.extra",
"get options.extra",
// CalendarFields
// lookup
"get this.calendar.fields",
"get this.calendar.mergeFields",
"get this.calendar.monthDayFromFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.day",
@ -40,10 +43,8 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// CalendarMergeFields
"get this.calendar.mergeFields",
"call this.calendar.mergeFields",
// CalendarMonthDayFromFields
"get this.calendar.monthDayFromFields",
"call this.calendar.monthDayFromFields",
// inside Calendar.p.monthDayFromFields
"get options.overflow.toString",

View File

@ -33,6 +33,7 @@ const expected = [
"has item.plainDate.calendar.year",
"has item.plainDate.calendar.yearMonthFromFields",
"has item.plainDate.calendar.yearOfWeek",
"get item.plainDate.calendar.dateFromFields",
"get item.plainDate.calendar.fields",
"call item.plainDate.calendar.fields",
"get item.plainDate.day",
@ -47,7 +48,6 @@ const expected = [
"get item.plainDate.year",
"get item.plainDate.year.valueOf",
"call item.plainDate.year.valueOf",
"get item.plainDate.calendar.dateFromFields",
"call item.plainDate.calendar.dateFromFields",
"get item.timeZone",
"has item.timeZone.getOffsetNanosecondsFor",

View File

@ -38,8 +38,10 @@ const expected = [
"has fields.calendar.year",
"has fields.calendar.yearMonthFromFields",
"has fields.calendar.yearOfWeek",
// CalendarFields
// lookup
"get fields.calendar.fields",
"get fields.calendar.yearMonthFromFields",
// CalendarFields
"call fields.calendar.fields",
// PrepareTemporalFields
"get fields.month",
@ -52,7 +54,6 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// CalendarYearMonthFromFields
"get fields.calendar.yearMonthFromFields",
"call fields.calendar.yearMonthFromFields",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",

View File

@ -40,8 +40,12 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// CalendarFields
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateFromFields",
"get this.calendar.fields",
"get this.calendar.yearMonthFromFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.monthCode",
@ -49,9 +53,7 @@ const expected = [
"get this.calendar.year",
"call this.calendar.year",
// CalendarDateFromFields
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
"get this.calendar.dateAdd",
// CopyDataProperties
"ownKeys options",
"getOwnPropertyDescriptor options.overflow",
@ -68,7 +70,6 @@ const expected = [
"get this.calendar.year",
"call this.calendar.year",
// CalendarYearMonthFromFields
"get this.calendar.yearMonthFromFields",
"call this.calendar.yearMonthFromFields",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",
@ -127,8 +128,11 @@ const noCalendarExpected = [
"call fields.seconds.valueOf",
"get fields.weeks",
"get fields.years",
// CalendarFields
// lookup
"get this.calendar.dateFromFields",
"get this.calendar.fields",
"get this.calendar.yearMonthFromFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.monthCode",
@ -136,9 +140,7 @@ const noCalendarExpected = [
"get this.calendar.year",
"call this.calendar.year",
// CalendarDateFromFields
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
"get this.calendar.dateAdd",
// SnapshotOwnProperties
"ownKeys options",
"getOwnPropertyDescriptor options.overflow",
@ -153,7 +155,6 @@ const noCalendarExpected = [
"get this.calendar.year",
"call this.calendar.year",
// CalendarYearMonthFromFields
"get this.calendar.yearMonthFromFields",
"call this.calendar.yearMonthFromFields",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",

View File

@ -33,6 +33,7 @@ const expectedMinimal = [
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.fields",
"get other.calendar.yearMonthFromFields",
"call other.calendar.fields",
"get other.month",
"get other.month.valueOf",
@ -43,7 +44,6 @@ const expectedMinimal = [
"get other.year",
"get other.year.valueOf",
"call other.year.valueOf",
"get other.calendar.yearMonthFromFields",
"call other.calendar.yearMonthFromFields",
// CalendarEquals
"get this.calendar.id",
@ -72,25 +72,26 @@ const expectedMinimal = [
];
const expected = expectedMinimal.concat([
// CalendarFields
// lookup
"get this.calendar.dateAdd",
"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",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// PrepareTemporalFields / CalendarDateFromFields (argument)
"get other.calendar.monthCode",
"call other.calendar.monthCode",
"get other.calendar.year",
"call other.calendar.year",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// CalendarDateUntil
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
]);
const actual = [];
@ -122,7 +123,28 @@ actual.splice(0);
// code path that skips RoundDuration:
instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 }));
assert.compareArray(actual, expected, "order of operations with no rounding");
assert.compareArray(actual, expectedMinimal.concat([
// 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
// short-circuit for identical objects:
@ -139,10 +161,8 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -158,7 +178,6 @@ const otherYearMonthPropertyBagSameMonth = TemporalHelpers.propertyBagObserver(a
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
}, "other");
const expectedOpsForYearRoundingSameMonth = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"call this.calendar.dateAdd", // 7.y MoveRelativeDate
@ -169,7 +188,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat([
"get this.calendar.dateAdd", // 10.b
"call this.calendar.dateAdd", // 10.c
"call this.calendar.dateAdd", // 10.e
"call this.calendar.dateAdd", // 10.k MoveRelativeDate

View File

@ -40,22 +40,23 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// CalendarFields
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateFromFields",
"get this.calendar.day",
"get this.calendar.fields",
"get this.calendar.yearMonthFromFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.monthCode",
"call this.calendar.monthCode",
"get this.calendar.year",
"call this.calendar.year",
// CalendarDaysInMonth
"get this.calendar.dateFromFields",
// calculate last day of month
"call this.calendar.dateFromFields",
"get this.calendar.dateAdd",
"call this.calendar.dateAdd",
"get this.calendar.day",
"call this.calendar.day",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// CopyDataProperties
"ownKeys options",
@ -73,7 +74,6 @@ const expected = [
"get this.calendar.year",
"call this.calendar.year",
// CalendarYearMonthFromFields
"get this.calendar.yearMonthFromFields",
"call this.calendar.yearMonthFromFields",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",
@ -132,8 +132,13 @@ const noCalendarExpected = [
"call fields.seconds.valueOf",
"get fields.weeks",
"get fields.years",
// CalendarFields
// lookup
"get this.calendar.dateAdd",
"get this.calendar.dateFromFields",
"get this.calendar.day",
"get this.calendar.fields",
"get this.calendar.yearMonthFromFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.monthCode",
@ -141,13 +146,10 @@ const noCalendarExpected = [
"get this.calendar.year",
"call this.calendar.year",
// CalendarDateFromFields
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
"get this.calendar.dateAdd",
// calculate last day of month
"call this.calendar.dateAdd",
"get this.calendar.day",
"call this.calendar.day",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// SnapshotOwnProperties
"ownKeys options",
@ -163,7 +165,6 @@ const noCalendarExpected = [
"get this.calendar.year",
"call this.calendar.year",
// CalendarYearMonthFromFields
"get this.calendar.yearMonthFromFields",
"call this.calendar.yearMonthFromFields",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",

View File

@ -33,6 +33,7 @@ const expectedMinimal = [
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.fields",
"get other.calendar.yearMonthFromFields",
"call other.calendar.fields",
"get other.month",
"get other.month.valueOf",
@ -43,7 +44,6 @@ const expectedMinimal = [
"get other.year",
"get other.year.valueOf",
"call other.year.valueOf",
"get other.calendar.yearMonthFromFields",
"call other.calendar.yearMonthFromFields",
// CalendarEquals
"get this.calendar.id",
@ -72,25 +72,26 @@ const expectedMinimal = [
];
const expected = expectedMinimal.concat([
// CalendarFields
// lookup
"get this.calendar.dateAdd",
"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",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// PrepareTemporalFields / CalendarDateFromFields (argument)
"get other.calendar.monthCode",
"call other.calendar.monthCode",
"get other.calendar.year",
"call other.calendar.year",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// CalendarDateUntil
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
]);
const actual = [];
@ -122,7 +123,28 @@ actual.splice(0);
// code path that skips RoundDuration:
instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 }));
assert.compareArray(actual, expected, "order of operations with no rounding");
assert.compareArray(actual, expectedMinimal.concat([
// 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
// short-circuit for identical objects:
@ -139,10 +161,8 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -158,7 +178,6 @@ const otherYearMonthPropertyBagSameMonth = TemporalHelpers.propertyBagObserver(a
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
}, "other");
const expectedOpsForYearRoundingSameMonth = expected.concat([
"get this.calendar.dateAdd", // 7.c.i
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"call this.calendar.dateAdd", // 7.y MoveRelativeDate
@ -169,7 +188,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat([
"get this.calendar.dateAdd", // 10.b
"call this.calendar.dateAdd", // 10.c
"call this.calendar.dateAdd", // 10.e
"call this.calendar.dateAdd", // 10.k MoveRelativeDate

View File

@ -18,8 +18,11 @@ const expected = [
"get options.overflow",
"getOwnPropertyDescriptor options.extra",
"get options.extra",
// CalendarFields
// lookup
"get this.calendar.fields",
"get this.calendar.mergeFields",
"get this.calendar.yearMonthFromFields",
// CalendarFields
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.month",
@ -39,10 +42,8 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// CalendarMergeFields
"get this.calendar.mergeFields",
"call this.calendar.mergeFields",
// CalendarYearMonthFromFields
"get this.calendar.yearMonthFromFields",
"call this.calendar.yearMonthFromFields",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",

View File

@ -32,8 +32,10 @@ const expected = [
"has fields.calendar.year",
"has fields.calendar.yearMonthFromFields",
"has fields.calendar.yearOfWeek",
// CalendarFields
// lookup
"get fields.calendar.dateFromFields",
"get fields.calendar.fields",
// CalendarFields
"call fields.calendar.fields",
// PrepareTemporalFields
"get fields.day",
@ -67,7 +69,6 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// InterpretTemporalDateTimeFields
"get fields.calendar.dateFromFields",
"call fields.calendar.dateFromFields",
// ToTemporalDisambiguation
"get options.disambiguation",

View File

@ -47,15 +47,16 @@ const expectedOne = [
"has one.calendar.year",
"has one.calendar.yearMonthFromFields",
"has one.calendar.yearOfWeek",
// CalendarFields
// lookup
"get one.calendar.dateFromFields",
"get one.calendar.fields",
// CalendarFields
"call one.calendar.fields",
// ToTemporalTimeZoneSlotValue
"has one.timeZone.getOffsetNanosecondsFor",
"has one.timeZone.getPossibleInstantsFor",
"has one.timeZone.id",
// InterpretTemporalDateTimeFields
"get one.calendar.dateFromFields",
"call one.calendar.dateFromFields",
// lookup
"get one.timeZone.getPossibleInstantsFor",
@ -86,15 +87,16 @@ const expectedTwo = [
"has two.calendar.year",
"has two.calendar.yearMonthFromFields",
"has two.calendar.yearOfWeek",
// CalendarFields
// lookup
"get two.calendar.dateFromFields",
"get two.calendar.fields",
// CalendarFields
"call two.calendar.fields",
// ToTemporalTimeZoneSlotValue
"has two.timeZone.getOffsetNanosecondsFor",
"has two.timeZone.getPossibleInstantsFor",
"has two.timeZone.id",
// InterpretTemporalDateTimeFields
"get two.calendar.dateFromFields",
"call two.calendar.dateFromFields",
// lookup
"get two.timeZone.getPossibleInstantsFor",

View File

@ -31,6 +31,7 @@ const expected = [
"has one.calendar.year",
"has one.calendar.yearMonthFromFields",
"has one.calendar.yearOfWeek",
"get one.calendar.dateFromFields",
"get one.calendar.fields",
"call one.calendar.fields",
// PrepareTemporalFields
@ -72,7 +73,6 @@ const expected = [
"has one.timeZone.getPossibleInstantsFor",
"has one.timeZone.id",
// InterpretTemporalDateTimeFields
"get one.calendar.dateFromFields",
"call one.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get one.timeZone.getPossibleInstantsFor",
@ -102,6 +102,7 @@ const expected = [
"has two.calendar.year",
"has two.calendar.yearMonthFromFields",
"has two.calendar.yearOfWeek",
"get two.calendar.dateFromFields",
"get two.calendar.fields",
"call two.calendar.fields",
// PrepareTemporalFields
@ -143,7 +144,6 @@ const expected = [
"has two.timeZone.getPossibleInstantsFor",
"has two.timeZone.id",
// InterpretTemporalDateTimeFields
"get two.calendar.dateFromFields",
"call two.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get two.timeZone.getPossibleInstantsFor",

View File

@ -42,15 +42,16 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",
"has timeZone.getPossibleInstantsFor",
"has timeZone.id",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
];

View File

@ -42,6 +42,7 @@ const expected = [
"has item.calendar.year",
"has item.calendar.yearMonthFromFields",
"has item.calendar.yearOfWeek",
"get item.calendar.dateFromFields",
"get item.calendar.fields",
"call item.calendar.fields",
// PrepareTemporalFields
@ -89,7 +90,6 @@ const expected = [
"call options.offset.toString",
"get options.overflow.toString",
"call options.overflow.toString",
"get item.calendar.dateFromFields",
"call item.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get item.timeZone.getPossibleInstantsFor",

View File

@ -43,9 +43,9 @@ const expected = [
// lookup
"get this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getPossibleInstantsFor",
"get this.calendar.dateAdd",
// AddZonedDateTime
"call this.timeZone.getOffsetNanosecondsFor",
"get this.calendar.dateAdd",
"call this.calendar.dateAdd",
// ... inside Calendar.p.dateAdd
"get options.overflow",

View File

@ -48,15 +48,16 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",
"has timeZone.getPossibleInstantsFor",
"has timeZone.id",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// lookup
"get timeZone.getPossibleInstantsFor",

View File

@ -31,6 +31,7 @@ const expected = [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
// PrepareTemporalFields
@ -72,7 +73,6 @@ const expected = [
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
// InterpretTemporalDateTimeFields
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get other.timeZone.getPossibleInstantsFor",

View File

@ -48,15 +48,16 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",
"has timeZone.getPossibleInstantsFor",
"has timeZone.id",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// lookup
"get timeZone.getPossibleInstantsFor",

View File

@ -32,6 +32,7 @@ const expected = [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -71,7 +72,6 @@ const expected = [
"has other.timeZone.getOffsetNanosecondsFor",
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
@ -223,6 +223,7 @@ assert.compareArray(actual, [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -262,7 +263,6 @@ assert.compareArray(actual, [
"has other.timeZone.getOffsetNanosecondsFor",
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
@ -300,6 +300,8 @@ assert.compareArray(actual, [
// lookup
"get this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getPossibleInstantsFor",
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// DifferenceZonedDateTime
"call this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
@ -319,15 +321,15 @@ const expectedOpsForCalendarDifference = [
// lookup
"get this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getPossibleInstantsFor",
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// precalculate PlainDateTime
"call this.timeZone.getOffsetNanosecondsFor",
// DifferenceZonedDateTime
"call this.timeZone.getOffsetNanosecondsFor",
// DifferenceISODateTime
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
// AddZonedDateTime
"get this.calendar.dateAdd",
"call this.calendar.dateAdd",
"call this.timeZone.getPossibleInstantsFor",
// NanosecondsToDays
@ -340,7 +342,6 @@ const expectedOpsForCalendarDifference = [
const expectedOpsForCalendarRounding = [
// RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
"get this.calendar.dateAdd",
"call this.calendar.dateAdd",
"call this.timeZone.getPossibleInstantsFor",
// RoundDuration → NanosecondsToDays
@ -357,10 +358,8 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [
"get this.calendar.dateAdd", // 7.c.i
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -370,7 +369,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [
"get this.calendar.dateAdd", // 10.b
"call this.calendar.dateAdd", // 10.c
"call this.calendar.dateAdd", // 10.e
"call this.calendar.dateAdd", // 10.k MoveRelativeDate
@ -381,7 +379,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest week:
const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [
"get this.calendar.dateAdd", // 11.c
"call this.calendar.dateAdd", // 11.d MoveRelativeDate
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));

View File

@ -43,9 +43,9 @@ const expected = [
// lookup
"get this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getPossibleInstantsFor",
"get this.calendar.dateAdd",
// AddZonedDateTime
"call this.timeZone.getOffsetNanosecondsFor",
"get this.calendar.dateAdd",
"call this.calendar.dateAdd",
// ... inside Calendar.p.dateAdd
"get options.overflow",

View File

@ -0,0 +1,48 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.toplainmonthday
description: >
User-observable time zone and calendar accesses and calls in
toPlainMonthDay() happen the correct order
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expected = [
"get this.calendar.fields",
"get this.calendar.monthDayFromFields",
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"call this.calendar.fields",
"get this.calendar.day",
"call this.calendar.day",
"get this.calendar.monthCode",
"call this.calendar.monthCode",
"call this.calendar.monthDayFromFields",
];
const actual = [];
const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar);
Object.defineProperties(instance, {
day: {
get() {
actual.push("get this.day");
return TemporalHelpers.toPrimitiveObserver(actual, 1, "this.day");
}
},
monthCode: {
get() {
actual.push("get this.monthCode");
return TemporalHelpers.toPrimitiveObserver(actual, "M01", "this.monthCode");
}
},
});
// clear observable operations that occurred during the constructor call
actual.splice(0);
instance.toPlainMonthDay();
assert.compareArray(actual, expected, "order of operations");

View File

@ -0,0 +1,48 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.prototype.toplainyearmonth
description: >
User-observable time zone and calendar accesses and calls in
toPlainYearMonth() happen the correct order
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const expected = [
"get this.calendar.fields",
"get this.calendar.yearMonthFromFields",
"get this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
"call this.calendar.fields",
"get this.calendar.monthCode",
"call this.calendar.monthCode",
"get this.calendar.year",
"call this.calendar.year",
"call this.calendar.yearMonthFromFields",
];
const actual = [];
const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar);
Object.defineProperties(instance, {
monthCode: {
get() {
actual.push("get this.monthCode");
return TemporalHelpers.toPrimitiveObserver(actual, "M01", "this.monthCode");
}
},
year: {
get() {
actual.push("get this.year");
return TemporalHelpers.toPrimitiveObserver(actual, 1970, "this.year");
}
},
});
// clear observable operations that occurred during the constructor call
actual.splice(0);
instance.toPlainYearMonth();
assert.compareArray(actual, expected, "order of operations");

View File

@ -48,15 +48,16 @@ const expected = [
"has calendar.year",
"has calendar.yearMonthFromFields",
"has calendar.yearOfWeek",
// CalendarFields
// lookup
"get calendar.dateFromFields",
"get calendar.fields",
// CalendarFields
"call calendar.fields",
// ToTemporalTimeZoneSlotValue
"has timeZone.getOffsetNanosecondsFor",
"has timeZone.getPossibleInstantsFor",
"has timeZone.id",
// InterpretTemporalDateTimeFields
"get calendar.dateFromFields",
"call calendar.dateFromFields",
// lookup
"get timeZone.getPossibleInstantsFor",

View File

@ -32,6 +32,7 @@ const expected = [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -71,7 +72,6 @@ const expected = [
"has other.timeZone.getOffsetNanosecondsFor",
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
@ -223,6 +223,7 @@ assert.compareArray(actual, [
"has other.calendar.year",
"has other.calendar.yearMonthFromFields",
"has other.calendar.yearOfWeek",
"get other.calendar.dateFromFields",
"get other.calendar.fields",
"call other.calendar.fields",
"get other.day",
@ -262,7 +263,6 @@ assert.compareArray(actual, [
"has other.timeZone.getOffsetNanosecondsFor",
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"get other.calendar.dateFromFields",
"call other.calendar.dateFromFields",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
@ -300,6 +300,8 @@ assert.compareArray(actual, [
// lookup
"get this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getPossibleInstantsFor",
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// DifferenceZonedDateTime
"call this.timeZone.getOffsetNanosecondsFor",
"call this.timeZone.getOffsetNanosecondsFor",
@ -319,15 +321,15 @@ const expectedOpsForCalendarDifference = [
// lookup
"get this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getPossibleInstantsFor",
"get this.calendar.dateAdd",
"get this.calendar.dateUntil",
// precalculate PlainDateTime
"call this.timeZone.getOffsetNanosecondsFor",
// DifferenceZonedDateTime
"call this.timeZone.getOffsetNanosecondsFor",
// DifferenceISODateTime
"get this.calendar.dateUntil",
"call this.calendar.dateUntil",
// AddZonedDateTime
"get this.calendar.dateAdd",
"call this.calendar.dateAdd",
"call this.timeZone.getPossibleInstantsFor",
// NanosecondsToDays
@ -340,7 +342,6 @@ const expectedOpsForCalendarDifference = [
const expectedOpsForCalendarRounding = [
// RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
"get this.calendar.dateAdd",
"call this.calendar.dateAdd",
"call this.timeZone.getPossibleInstantsFor",
// RoundDuration → NanosecondsToDays
@ -357,10 +358,8 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest year:
const expectedOpsForYearRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [
"get this.calendar.dateAdd", // 7.c.i
"call this.calendar.dateAdd", // 7.e
"call this.calendar.dateAdd", // 7.g
"get this.calendar.dateUntil", // 7.o
"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)
@ -370,7 +369,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest month:
const expectedOpsForMonthRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [
"get this.calendar.dateAdd", // 10.b
"call this.calendar.dateAdd", // 10.c
"call this.calendar.dateAdd", // 10.e
"call this.calendar.dateAdd", // 10.k MoveRelativeDate
@ -381,7 +379,6 @@ actual.splice(0); // clear
// code path through RoundDuration that rounds to the nearest week:
const expectedOpsForWeekRounding = expected.concat(expectedOpsForCalendarDifference, expectedOpsForCalendarRounding, [
"get this.calendar.dateAdd", // 11.c
"call this.calendar.dateAdd", // 11.d MoveRelativeDate
]); // (11.g.iii MoveRelativeDate not called because days already balanced)
instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" }));

View File

@ -23,12 +23,15 @@ const expected = [
"getOwnPropertyDescriptor options.extra",
"get options.extra",
// lookup
"get this.calendar.dateFromFields",
"get this.calendar.fields",
"get this.calendar.mergeFields",
// lookup
"get this.timeZone.getOffsetNanosecondsFor",
"get this.timeZone.getPossibleInstantsFor",
// GetOffsetNanosecondsFor on receiver
"call this.timeZone.getOffsetNanosecondsFor",
// CalendarFields
"get this.calendar.fields",
"call this.calendar.fields",
// PrepareTemporalFields on receiver
"get this.calendar.day",
@ -74,7 +77,6 @@ const expected = [
"get fields.year.valueOf",
"call fields.year.valueOf",
// CalendarMergeFields
"get this.calendar.mergeFields",
"call this.calendar.mergeFields",
// InterpretTemporalDateTimeFields
"get options.disambiguation.toString",
@ -83,7 +85,6 @@ const expected = [
"call options.offset.toString",
"get options.overflow.toString",
"call options.overflow.toString",
"get this.calendar.dateFromFields",
"call this.calendar.dateFromFields",
// InterpretISODateTimeOffset
"call this.timeZone.getPossibleInstantsFor",

View File

@ -33,6 +33,7 @@ const expected = [
"has plainDateLike.calendar.year",
"has plainDateLike.calendar.yearMonthFromFields",
"has plainDateLike.calendar.yearOfWeek",
"get plainDateLike.calendar.dateFromFields",
"get plainDateLike.calendar.fields",
"call plainDateLike.calendar.fields",
"get plainDateLike.day",
@ -47,7 +48,6 @@ const expected = [
"get plainDateLike.year",
"get plainDateLike.year.valueOf",
"call plainDateLike.year.valueOf",
"get plainDateLike.calendar.dateFromFields",
"call plainDateLike.calendar.dateFromFields",
// lookup
"get this.timeZone.getOffsetNanosecondsFor",