Temporal: Add TemporalHelpers.timeZoneObserver

Similar to the previous commit with property bags, many existing tests use
a Proxy to test the order of observable operations which involve user code
passed in as part of a Temporal.TimeZone object. I am going to write
several more tests that do this, as well. This seems like a good thing to
put into TemporalHelpers, where it can be implemented consistently so that
we don't get discrepancies in which operations are tracked.

Updates existing tests to use this helper.
This commit is contained in:
Philip Chimento 2022-09-20 12:18:21 -07:00 committed by Ms2ger
parent 534b94eb63
commit 12f919e45d
15 changed files with 75 additions and 250 deletions

View File

@ -1635,6 +1635,44 @@ var TemporalHelpers = {
return new SpringForwardFallBackTimeZone(); return new SpringForwardFallBackTimeZone();
}, },
/*
* timeZoneObserver:
* A custom calendar that behaves exactly like the UTC time zone but tracks
* calls to any of its methods, and Get/Has operations on its properties, by
* appending messages to an array. This is for the purpose of testing order of
* operations that are observable from user code. objectName is used in the
* log. methodOverrides is an optional object containing properties with the
* same name as Temporal.TimeZone methods. If the property value is a function
* it will be called with the proper arguments instead of the UTC method.
* Otherwise, the property value will be returned directly.
*/
timeZoneObserver(calls, objectName, methodOverrides = {}) {
const utc = new Temporal.TimeZone("UTC");
const trackingMethods = {};
// Automatically generate the methods
["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => {
trackingMethods[methodName] = function (...args) {
actual.push(`call ${formatPropertyName(methodName, objectName)}`);
if (methodName in methodOverrides) {
const value = methodOverrides[methodName];
return typeof value === "function" ? value(...args) : value;
}
return utc[methodName](...args);
};
});
return new Proxy(trackingMethods, {
get(target, key, receiver) {
const result = Reflect.get(target, key, receiver);
actual.push(`get ${formatPropertyName(key, objectName)}`);
return result;
},
has(target, key) {
actual.push(`has ${formatPropertyName(key, objectName)}`);
return Reflect.has(target, key);
},
});
},
/* /*
* Returns an object that will append logs of any Gets or Calls of its valueOf * Returns an object that will append logs of any Gets or Calls of its valueOf
* or toString properties to the array calls. Both valueOf and toString will * or toString properties to the array calls. Both valueOf and toString will

View File

@ -18,28 +18,12 @@ const expected = [
]; ];
const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456Z"); const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456Z");
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
name: "Custom/TimeZone", toString: TemporalHelpers.toPrimitiveObserver(actual, "Custom/TimeZone", "name"),
toString() {
actual.push("call timeZone.toString");
return TemporalHelpers.toPrimitiveObserver(actual, "Custom/TimeZone", "name");
},
getOffsetNanosecondsFor(instantArg) { getOffsetNanosecondsFor(instantArg) {
actual.push("call timeZone.getOffsetNanosecondsFor");
assert.sameValue(instantArg.epochNanoseconds, instant.epochNanoseconds); assert.sameValue(instantArg.epochNanoseconds, instant.epochNanoseconds);
return -8735135801679; return -8735135801679;
}, },
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
Object.defineProperty(Temporal.TimeZone, "from", { Object.defineProperty(Temporal.TimeZone, "from", {

View File

@ -4,7 +4,7 @@
/*--- /*---
esid: sec-temporal.instant.prototype.tozoneddatetime esid: sec-temporal.instant.prototype.tozoneddatetime
description: TimeZone.getPlainDateTimeFor is not called description: TimeZone.getPlainDateTimeFor is not called
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [Temporal] features: [Temporal]
---*/ ---*/
@ -14,22 +14,9 @@ const expected = [
]; ];
const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789Z"); const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789Z");
const dateTime = Temporal.PlainDateTime.from("1963-07-02T12:00:00.987654321");
const calendar = Temporal.Calendar.from("iso8601"); const calendar = Temporal.Calendar.from("iso8601");
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getPlainDateTimeFor() { getPlainDateTimeFor: Temporal.PlainDateTime.from("1963-07-02T12:00:00.987654321"),
actual.push("call timeZone.getPlainDateTimeFor");
return dateTime;
}
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
const result = instant.toZonedDateTime({ timeZone, calendar }); const result = instant.toZonedDateTime({ timeZone, calendar });

View File

@ -4,7 +4,7 @@
/*--- /*---
esid: sec-temporal.now.plaindate esid: sec-temporal.now.plaindate
description: PlainDateTime.toPlainDate is not observably called description: PlainDateTime.toPlainDate is not observably called
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [Temporal] features: [Temporal]
---*/ ---*/
@ -24,21 +24,11 @@ Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainDate", {
}, },
}); });
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push("call timeZone.getOffsetNanosecondsFor");
assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
return 86399_999_999_999; return 86399_999_999_999;
}, },
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
const result = Temporal.Now.plainDate("iso8601", timeZone); const result = Temporal.Now.plainDate("iso8601", timeZone);

View File

@ -3,7 +3,7 @@
/*--- /*---
esid: sec-temporal.now.plaindatetime esid: sec-temporal.now.plaindatetime
description: Behavior when provided calendar value is a function description: Behavior when provided calendar value is a function
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [BigInt, Proxy, Temporal] features: [BigInt, Proxy, Temporal]
---*/ ---*/
const actual = []; const actual = [];
@ -16,21 +16,10 @@ const expected = [
const calendar = function() {}; const calendar = function() {};
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call timeZone.getOffsetNanosecondsFor');
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
}
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
}, },
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
}
}); });
Object.defineProperty(Temporal.Calendar, 'from', { Object.defineProperty(Temporal.Calendar, 'from', {

View File

@ -3,7 +3,7 @@
/*--- /*---
esid: sec-temporal.now.plaindatetime esid: sec-temporal.now.plaindatetime
description: Observable interactions with the provided timezone-like object description: Observable interactions with the provided timezone-like object
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [BigInt, Proxy, Temporal] features: [BigInt, Proxy, Temporal]
---*/ ---*/
const actual = []; const actual = [];
@ -16,10 +16,8 @@ const expected = [
'call nestedTimeZone.getOffsetNanosecondsFor' 'call nestedTimeZone.getOffsetNanosecondsFor'
]; ];
const nestedTimeZone = new Proxy({ const nestedTimeZone = TemporalHelpers.timeZoneObserver(actual, "nestedTimeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call nestedTimeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -28,24 +26,10 @@ const nestedTimeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has nestedTimeZone.${String(property)}`);
return property in target;
},
get(target, property) {
actual.push(`get nestedTimeZone.${String(property)}`);
return target[property];
}
}); });
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
timeZone: nestedTimeZone,
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call timeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -54,17 +38,8 @@ const timeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
}
}); });
timeZone.timeZone = nestedTimeZone;
Object.defineProperty(Temporal.TimeZone, 'from', { Object.defineProperty(Temporal.TimeZone, 'from', {
get() { get() {

View File

@ -4,7 +4,7 @@
/*--- /*---
esid: sec-temporal.now.plaindatetime esid: sec-temporal.now.plaindatetime
description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [Temporal] features: [Temporal]
---*/ ---*/
@ -15,21 +15,11 @@ const expected = [
"call timeZone.getOffsetNanosecondsFor", "call timeZone.getOffsetNanosecondsFor",
]; ];
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push("call timeZone.getOffsetNanosecondsFor");
assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
return -Number(instant.epochNanoseconds % 86400_000_000_000n); return -Number(instant.epochNanoseconds % 86400_000_000_000n);
}, },
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
const calendar = Temporal.Calendar.from("iso8601"); const calendar = Temporal.Calendar.from("iso8601");

View File

@ -3,7 +3,7 @@
/*--- /*---
esid: sec-temporal.now.plaindatetimeiso esid: sec-temporal.now.plaindatetimeiso
description: Observable interactions with the provided timezone-like object description: Observable interactions with the provided timezone-like object
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [BigInt, Proxy, Temporal] features: [BigInt, Proxy, Temporal]
---*/ ---*/
const actual = []; const actual = [];
@ -16,10 +16,8 @@ const expected = [
'call nestedTimeZone.getOffsetNanosecondsFor' 'call nestedTimeZone.getOffsetNanosecondsFor'
]; ];
const nestedTimeZone = new Proxy({ const nestedTimeZone = TemporalHelpers.timeZoneObserver(actual, "nestedTimeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call nestedTimeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -28,24 +26,10 @@ const nestedTimeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has nestedTimeZone.${String(property)}`);
return property in target;
},
get(target, property) {
actual.push(`get nestedTimeZone.${String(property)}`);
return target[property];
}
}); });
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
timeZone: nestedTimeZone,
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call timeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -54,17 +38,8 @@ const timeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
}
}); });
timeZone.timeZone = nestedTimeZone;
Object.defineProperty(Temporal.TimeZone, 'from', { Object.defineProperty(Temporal.TimeZone, 'from', {
get() { get() {

View File

@ -4,7 +4,7 @@
/*--- /*---
esid: sec-temporal.now.plaintimeiso esid: sec-temporal.now.plaintimeiso
description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [Temporal] features: [Temporal]
---*/ ---*/
@ -15,21 +15,11 @@ const expected = [
"call timeZone.getOffsetNanosecondsFor", "call timeZone.getOffsetNanosecondsFor",
]; ];
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push("call timeZone.getOffsetNanosecondsFor");
assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
return -Number(instant.epochNanoseconds % 86400_000_000_000n); return -Number(instant.epochNanoseconds % 86400_000_000_000n);
}, },
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
const result = Temporal.Now.plainTimeISO(timeZone); const result = Temporal.Now.plainTimeISO(timeZone);

View File

@ -4,7 +4,7 @@
/*--- /*---
esid: sec-temporal.now.plaintimeiso esid: sec-temporal.now.plaintimeiso
description: PlainDateTime.toPlainTime is not observably called description: PlainDateTime.toPlainTime is not observably called
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [Temporal] features: [Temporal]
---*/ ---*/
@ -24,21 +24,11 @@ Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainTime", {
}, },
}); });
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push("call timeZone.getOffsetNanosecondsFor");
assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
return -Number(instant.epochNanoseconds % 86400_000_000_000n); return -Number(instant.epochNanoseconds % 86400_000_000_000n);
}, },
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
const result = Temporal.Now.plainTimeISO(timeZone); const result = Temporal.Now.plainTimeISO(timeZone);

View File

@ -3,7 +3,7 @@
/*--- /*---
esid: sec-temporal.now.zoneddatetime esid: sec-temporal.now.zoneddatetime
description: Behavior when provided calendar value is a function description: Behavior when provided calendar value is a function
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [BigInt, Proxy, Temporal] features: [BigInt, Proxy, Temporal]
---*/ ---*/
const actual = []; const actual = [];
@ -14,21 +14,10 @@ const expected = [
const calendar = function() {}; const calendar = function() {};
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call timeZone.getOffsetNanosecondsFor');
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
}
}); });
Object.defineProperty(Temporal.Calendar, 'from', { Object.defineProperty(Temporal.Calendar, 'from', {

View File

@ -3,7 +3,7 @@
/*--- /*---
esid: sec-temporal.now.zoneddatetime esid: sec-temporal.now.zoneddatetime
description: Observable interactions with the provided timezone-like object description: Observable interactions with the provided timezone-like object
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [BigInt, Proxy, Temporal] features: [BigInt, Proxy, Temporal]
---*/ ---*/
const actual = []; const actual = [];
@ -14,10 +14,8 @@ const expected = [
'has nestedTimeZone.timeZone' 'has nestedTimeZone.timeZone'
]; ];
const nestedTimeZone = new Proxy({ const nestedTimeZone = TemporalHelpers.timeZoneObserver(actual, "nestedTimeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call nestedTimeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -26,24 +24,10 @@ const nestedTimeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has nestedTimeZone.${String(property)}`);
return property in target;
},
get(target, property) {
actual.push(`get nestedTimeZone.${String(property)}`);
return target[property];
}
}); });
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
timeZone: nestedTimeZone,
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call timeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -52,17 +36,8 @@ const timeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
}
}); });
timeZone.timeZone = nestedTimeZone;
Object.defineProperty(Temporal.TimeZone, 'from', { Object.defineProperty(Temporal.TimeZone, 'from', {
get() { get() {

View File

@ -3,7 +3,7 @@
/*--- /*---
esid: sec-temporal.now.zoneddatetime esid: sec-temporal.now.zoneddatetime
description: Observable interactions with the provided timezone-like object description: Observable interactions with the provided timezone-like object
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [BigInt, Proxy, Temporal] features: [BigInt, Proxy, Temporal]
---*/ ---*/
const actual = []; const actual = [];
@ -14,10 +14,8 @@ const expected = [
'has nestedTimeZone.timeZone' 'has nestedTimeZone.timeZone'
]; ];
const nestedTimeZone = new Proxy({ const nestedTimeZone = TemporalHelpers.timeZoneObserver(actual, "nestedTimeZone", {
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call nestedTimeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -26,24 +24,10 @@ const nestedTimeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has nestedTimeZone.${String(property)}`);
return property in target;
},
get(target, property) {
actual.push(`get nestedTimeZone.${String(property)}`);
return target[property];
}
}); });
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
timeZone: nestedTimeZone,
getOffsetNanosecondsFor(instant) { getOffsetNanosecondsFor(instant) {
actual.push('call timeZone.getOffsetNanosecondsFor');
assert.sameValue( assert.sameValue(
instant instanceof Temporal.Instant, instant instanceof Temporal.Instant,
true, true,
@ -52,17 +36,8 @@ const timeZone = new Proxy({
return -Number(instant.epochNanoseconds % 86400000000000n); return -Number(instant.epochNanoseconds % 86400000000000n);
} }
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
}
}); });
timeZone.timeZone = nestedTimeZone;
Object.defineProperty(Temporal.TimeZone, 'from', { Object.defineProperty(Temporal.TimeZone, 'from', {
get() { get() {

View File

@ -30,21 +30,11 @@ const instant = Temporal.Instant.fromEpochNanoseconds(-205156799012345679n);
const options = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "reject" }, "options"); const options = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "reject" }, "options");
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getPossibleInstantsFor(dateTimeArg) { getPossibleInstantsFor(dateTimeArg) {
actual.push("call timeZone.getPossibleInstantsFor");
assert.sameValue(dateTimeArg, dateTime); assert.sameValue(dateTimeArg, dateTime);
return [instant]; return [instant];
}, },
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
const result = dateTime.toZonedDateTime(timeZone, options); const result = dateTime.toZonedDateTime(timeZone, options);

View File

@ -4,7 +4,7 @@
/*--- /*---
esid: sec-temporal.zoneddatetime.prototype.toplaindatetime esid: sec-temporal.zoneddatetime.prototype.toplaindatetime
description: timeZone.getOffsetNanosecondsFor() called description: timeZone.getOffsetNanosecondsFor() called
includes: [compareArray.js] includes: [compareArray.js, temporalHelpers.js]
features: [Temporal] features: [Temporal]
---*/ ---*/
@ -15,20 +15,8 @@ const expected = [
"call timeZone.getOffsetNanosecondsFor", "call timeZone.getOffsetNanosecondsFor",
]; ];
const timeZone = new Proxy({ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
getOffsetNanosecondsFor() { getOffsetNanosecondsFor: -8735135802468,
actual.push("call timeZone.getOffsetNanosecondsFor");
return -8735135802468;
},
}, {
has(target, property) {
actual.push(`has timeZone.${property}`);
return property in target;
},
get(target, property) {
actual.push(`get timeZone.${property}`);
return target[property];
},
}); });
const zdt = new Temporal.ZonedDateTime(160583136123456789n, timeZone); const zdt = new Temporal.ZonedDateTime(160583136123456789n, timeZone);