Temporal: Make time zone method lookups unconditional

See https://github.com/tc39/proposal-temporal/issues/2724
This commit is contained in:
Philip Chimento 2023-11-10 13:37:47 -08:00 committed by Philip Chimento
parent 7c41695f78
commit 3e23610431
14 changed files with 33 additions and 39 deletions

View File

@ -34,8 +34,10 @@ const expected = [
"get item.plainTime.second",
"get item.plainTime.second.valueOf",
"call item.plainTime.second.valueOf",
// GetInstantFor
// lookup in PlainDate.p.toZonedDateTime
"get item.timeZone.getOffsetNanosecondsFor",
"get item.timeZone.getPossibleInstantsFor",
// GetInstantFor
"call item.timeZone.getPossibleInstantsFor",
];
@ -86,7 +88,6 @@ actual.splice(0); // clear
springForwardInstance.toZonedDateTime(item);
assert.compareArray(actual, expected.concat([
"get item.timeZone.getOffsetNanosecondsFor",
"call item.timeZone.getOffsetNanosecondsFor",
"call item.timeZone.getOffsetNanosecondsFor",
"call item.timeZone.getPossibleInstantsFor",

View File

@ -17,8 +17,10 @@ const expected = [
"get options.disambiguation",
"get options.disambiguation.toString",
"call options.disambiguation.toString",
// BuiltinTimeZoneGetInstantFor
// lookup in PlainDateTime.p.toZonedDateTime
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// GetInstantFor
"call timeZone.getPossibleInstantsFor",
];
const actual = [];
@ -48,7 +50,6 @@ actual.splice(0); // clear
springForwardInstance.toZonedDateTime(timeZone, options);
assert.compareArray(actual, expected.concat([
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",

View File

@ -16,6 +16,7 @@ const expected = [
"get options.disambiguation",
"get options.disambiguation.toString",
"call options.disambiguation.toString",
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
"call timeZone.getPossibleInstantsFor",
];

View File

@ -53,6 +53,7 @@ const expected = [
"has item.timeZone.getOffsetNanosecondsFor",
"has item.timeZone.getPossibleInstantsFor",
"has item.timeZone.id",
"get item.timeZone.getOffsetNanosecondsFor",
"get item.timeZone.getPossibleInstantsFor",
"call item.timeZone.getPossibleInstantsFor",
];
@ -107,7 +108,6 @@ instance.toZonedDateTime(TemporalHelpers.propertyBagObserver(actual, {
timeZone,
}, "item"));
assert.compareArray(actual, expected.concat([
"get item.timeZone.getOffsetNanosecondsFor",
"call item.timeZone.getOffsetNanosecondsFor",
"call item.timeZone.getOffsetNanosecondsFor",
"call item.timeZone.getPossibleInstantsFor",

View File

@ -59,6 +59,7 @@ const expectedOne = [
// InterpretTemporalDateTimeFields
"call one.calendar.dateFromFields",
// lookup
"get one.timeZone.getOffsetNanosecondsFor",
"get one.timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call one.timeZone.getPossibleInstantsFor",
@ -99,6 +100,7 @@ const expectedTwo = [
// InterpretTemporalDateTimeFields
"call two.calendar.dateFromFields",
// lookup
"get two.timeZone.getOffsetNanosecondsFor",
"get two.timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call two.timeZone.getPossibleInstantsFor",
@ -111,13 +113,11 @@ Temporal.ZonedDateTime.compare(
const expectedSpringForward = expectedOne.concat([
// DisambiguatePossibleInstants
"get one.timeZone.getOffsetNanosecondsFor",
"call one.timeZone.getOffsetNanosecondsFor",
"call one.timeZone.getOffsetNanosecondsFor",
"call one.timeZone.getPossibleInstantsFor",
], expectedTwo, [
// DisambiguatePossibleInstants
"get two.timeZone.getOffsetNanosecondsFor",
"call two.timeZone.getOffsetNanosecondsFor",
"call two.timeZone.getOffsetNanosecondsFor",
"call two.timeZone.getPossibleInstantsFor",

View File

@ -75,9 +75,9 @@ const expected = [
// InterpretTemporalDateTimeFields
"call one.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get one.timeZone.getOffsetNanosecondsFor",
"get one.timeZone.getPossibleInstantsFor",
"call one.timeZone.getPossibleInstantsFor",
"get one.timeZone.getOffsetNanosecondsFor",
"call one.timeZone.getOffsetNanosecondsFor",
// Same set of operations, for the other argument:
"get two.calendar",
@ -146,9 +146,9 @@ const expected = [
// InterpretTemporalDateTimeFields
"call two.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get two.timeZone.getOffsetNanosecondsFor",
"get two.timeZone.getPossibleInstantsFor",
"call two.timeZone.getPossibleInstantsFor",
"get two.timeZone.getOffsetNanosecondsFor",
"call two.timeZone.getOffsetNanosecondsFor",
];
const actual = [];

View File

@ -53,6 +53,9 @@ const expected = [
"has timeZone.id",
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup in ToTemporalZonedDateTime
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
];
Temporal.ZonedDateTime.from(
@ -67,12 +70,9 @@ Temporal.ZonedDateTime.from(
{ offset: "ignore" }
);
assert.compareArray(actual, expected.concat([
// lookup
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",
@ -84,12 +84,9 @@ Temporal.ZonedDateTime.from(
{ offset: "prefer" }
);
assert.compareArray(actual, expected.concat([
// lookup
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",
@ -108,8 +105,6 @@ Temporal.ZonedDateTime.from(
{ offset: "ignore" }
);
assert.compareArray(actual, expected.concat([
// lookup
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
]), "order of operations converting property bag at repeated wall-clock time with offset: ignore");
@ -120,11 +115,8 @@ Temporal.ZonedDateTime.from(
{ offset: "prefer" }
);
assert.compareArray(actual, expected.concat([
// lookup
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
]), "order of operations converting property bag at repeated wall-clock time with offset: prefer");
@ -135,11 +127,8 @@ Temporal.ZonedDateTime.from(
{ offset: "reject" }
);
assert.compareArray(actual, expected.concat([
// lookup
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
]), "order of operations converting property bag at repeated wall-clock time with offset: reject");

View File

@ -91,10 +91,11 @@ const expected = [
"get options.overflow.toString",
"call options.overflow.toString",
"call item.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get item.timeZone.getPossibleInstantsFor",
"call item.timeZone.getPossibleInstantsFor",
// lookup in ToTemporalZonedDateTime
"get item.timeZone.getOffsetNanosecondsFor",
"get item.timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call item.timeZone.getPossibleInstantsFor",
"call item.timeZone.getOffsetNanosecondsFor",
];
const actual = [];

View File

@ -59,7 +59,8 @@ const expected = [
"has timeZone.id",
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup
// lookup in ToTemporalZonedDateTime
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
@ -67,7 +68,6 @@ const expected = [
const expectedSpringForward = expected.concat([
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",

View File

@ -74,10 +74,11 @@ const expected = [
"has other.timeZone.id",
// InterpretTemporalDateTimeFields
"call other.calendar.dateFromFields",
// InterpretISODateTimeOffset
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
// lookup in ToTemporalZonedDateTime
"get other.timeZone.getOffsetNanosecondsFor",
"get other.timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getOffsetNanosecondsFor",
// TimeZoneEquals
"get this.timeZone.id",

View File

@ -59,7 +59,8 @@ const expected = [
"has timeZone.id",
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup
// lookup in ToTemporalZonedDateTime
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
@ -67,7 +68,6 @@ const expected = [
const expectedSpringForward = expected.concat([
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",

View File

@ -73,9 +73,9 @@ const expected = [
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"call other.calendar.dateFromFields",
"get other.timeZone.getOffsetNanosecondsFor",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
"get other.timeZone.getOffsetNanosecondsFor",
"call other.timeZone.getOffsetNanosecondsFor",
// CalendarEquals
"get this.calendar.id",
@ -264,9 +264,9 @@ assert.compareArray(actual, [
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"call other.calendar.dateFromFields",
"get other.timeZone.getOffsetNanosecondsFor",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
"get other.timeZone.getOffsetNanosecondsFor",
"call other.timeZone.getOffsetNanosecondsFor",
// NOTE: extra because of wall-clock time ambiguity:
"call other.timeZone.getOffsetNanosecondsFor",

View File

@ -59,7 +59,8 @@ const expected = [
"has timeZone.id",
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup
// lookup in ToTemporalZonedDateTime
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
@ -67,7 +68,6 @@ const expected = [
const expectedSpringForward = expected.concat([
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",

View File

@ -73,9 +73,9 @@ const expected = [
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"call other.calendar.dateFromFields",
"get other.timeZone.getOffsetNanosecondsFor",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
"get other.timeZone.getOffsetNanosecondsFor",
"call other.timeZone.getOffsetNanosecondsFor",
// CalendarEquals
"get this.calendar.id",
@ -264,9 +264,9 @@ assert.compareArray(actual, [
"has other.timeZone.getPossibleInstantsFor",
"has other.timeZone.id",
"call other.calendar.dateFromFields",
"get other.timeZone.getOffsetNanosecondsFor",
"get other.timeZone.getPossibleInstantsFor",
"call other.timeZone.getPossibleInstantsFor",
"get other.timeZone.getOffsetNanosecondsFor",
"call other.timeZone.getOffsetNanosecondsFor",
// NOTE: extra because of wall-clock time ambiguity:
"call other.timeZone.getOffsetNanosecondsFor",