Skip to content

Commit

Permalink
Temporal: Make time zone method lookups unconditional
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed Nov 10, 2023
1 parent 2a804d6 commit 7bfb70b
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ const expected = [
"get item.plainTime.second",
"get item.plainTime.second.valueOf",
"call item.plainTime.second.valueOf",
// GetInstantFor
// lookup
"get item.timeZone.getOffsetNanosecondsFor",
"get item.timeZone.getPossibleInstantsFor",
// GetInstantFor
"call item.timeZone.getPossibleInstantsFor",
];

Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ const expected = [
"get options.disambiguation",
"get options.disambiguation.toString",
"call options.disambiguation.toString",
// BuiltinTimeZoneGetInstantFor
// lookup
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// GetInstantFor
"call timeZone.getPossibleInstantsFor",
];
const actual = [];
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
];
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const expected = [
"has timeZone.id",
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
];

Temporal.ZonedDateTime.from(
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ const expected = [
"get options.overflow.toString",
"call options.overflow.toString",
"call item.calendar.dateFromFields",
// InterpretISODateTimeOffset
// lookup
"get item.timeZone.getOffsetNanosecondsFor",
"get item.timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call item.timeZone.getPossibleInstantsFor",
"get item.timeZone.getOffsetNanosecondsFor",
"call item.timeZone.getOffsetNanosecondsFor",
];
const actual = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const expected = [
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
];

const expectedSpringForward = expected.concat([
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ const expected = [
"has other.timeZone.id",
// InterpretTemporalDateTimeFields
"call other.calendar.dateFromFields",
// InterpretISODateTimeOffset
// lookup
"get other.timeZone.getOffsetNanosecondsFor",
"get other.timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call other.timeZone.getPossibleInstantsFor",
"get other.timeZone.getOffsetNanosecondsFor",
"call other.timeZone.getOffsetNanosecondsFor",
// TimeZoneEquals
"get this.timeZone.id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const expected = [
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
];

const expectedSpringForward = expected.concat([
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const expected = [
// InterpretTemporalDateTimeFields
"call calendar.dateFromFields",
// lookup
"get timeZone.getOffsetNanosecondsFor",
"get timeZone.getPossibleInstantsFor",
// InterpretISODateTimeOffset
"call timeZone.getPossibleInstantsFor",
];

const expectedSpringForward = expected.concat([
// DisambiguatePossibleInstants
"get timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getOffsetNanosecondsFor",
"call timeZone.getPossibleInstantsFor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 7bfb70b

Please sign in to comment.