Temporal: Test change from MergeLargestUnitOption to CopyDataProperties

This tests some of the normative changes in
https://github.com/tc39/proposal-temporal/pull/2245, which achieved
consensus in the July 2022 TC39 meeting, specifically as they apply to
places where the MergeLargestUnitOperation was called.

Due to the use of the pre-existing spec operation CopyDataProperties, the
order of observable property operations has changed from a batch of
[[GetOwnProperty]] followed by a batch of [[Get]], to a series of
interleaved [[GetOwnProperty]]/[[Get]] pairs. This previously wasn't
tested because TemporalHelpers.propertyBagObserver didn't track
[[GetOwnProperty]] operations, but now it does.
This commit is contained in:
Philip Chimento 2022-10-17 17:37:39 -07:00 committed by Ms2ger
parent dfbeca3c79
commit 99bc91e0f5
13 changed files with 74 additions and 8 deletions

View File

@ -1612,6 +1612,10 @@ var TemporalHelpers = {
calls.push(`ownKeys ${objectName}`); calls.push(`ownKeys ${objectName}`);
return Reflect.ownKeys(target); return Reflect.ownKeys(target);
}, },
getOwnPropertyDescriptor(target, key) {
calls.push(`getOwnPropertyDescriptor ${formatPropertyName(key, objectName)}`);
return Reflect.getOwnPropertyDescriptor(target, key);
},
get(target, key, receiver) { get(target, key, receiver) {
calls.push(`get ${formatPropertyName(key, objectName)}`); calls.push(`get ${formatPropertyName(key, objectName)}`);
const result = Reflect.get(target, key, receiver); const result = Reflect.get(target, key, receiver);

View File

@ -48,12 +48,17 @@ const expected = [
"get options.roundingIncrement", "get options.roundingIncrement",
"get options.roundingIncrement.valueOf", "get options.roundingIncrement.valueOf",
"call options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// CalendarDateUntil // CalendarDateUntil
"get this.calendar.dateUntil", "get this.calendar.dateUntil",

View File

@ -48,12 +48,17 @@ const expected = [
"get options.roundingIncrement", "get options.roundingIncrement",
"get options.roundingIncrement.valueOf", "get options.roundingIncrement.valueOf",
"call options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// CalendarDateUntil // CalendarDateUntil
"get this.calendar.dateUntil", "get this.calendar.dateUntil",

View File

@ -66,12 +66,17 @@ const expected = [
"get options.roundingIncrement", "get options.roundingIncrement",
"get options.roundingIncrement.valueOf", "get options.roundingIncrement.valueOf",
"call options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// CalendarDateUntil // CalendarDateUntil
"get this.calendar.dateUntil", "get this.calendar.dateUntil",

View File

@ -66,12 +66,17 @@ const expected = [
"get options.roundingIncrement", "get options.roundingIncrement",
"get options.roundingIncrement.valueOf", "get options.roundingIncrement.valueOf",
"call options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// CalendarDateUntil // CalendarDateUntil
"get this.calendar.dateUntil", "get this.calendar.dateUntil",

View File

@ -14,9 +14,14 @@ features: [Temporal]
const actual = []; const actual = [];
const expected = [ const expected = [
// CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.extra",
"get options.extra", "get options.extra",
// Temporal.Calendar.prototype.dateAdd
"get options.overflow", "get options.overflow",
// overwriting property in custom calendar dateAdd
"getOwnPropertyDescriptor options.overflow",
]; ];
const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options"); const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options");

View File

@ -14,11 +14,17 @@ features: [Temporal]
const actual = []; const actual = [];
const expected = [ const expected = [
// CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.overflow",
"get options.overflow", "get options.overflow",
// Temporal.Calendar.prototype.dateAdd
"get options.overflow", "get options.overflow",
"get options.overflow.toString", "get options.overflow.toString",
"call options.overflow.toString", "call options.overflow.toString",
// overwriting property in custom calendar dateAdd
"getOwnPropertyDescriptor options.overflow",
// Temporal.Calendar.prototype.yearMonthFromFields (toPrimitiveObserver copied but not options object)
"get options.overflow.toString", "get options.overflow.toString",
"call options.overflow.toString", "call options.overflow.toString",
]; ];

View File

@ -60,12 +60,17 @@ const expected = [
"call this.calendar.year", "call this.calendar.year",
"get this.calendar.dateFromFields", "get this.calendar.dateFromFields",
"call this.calendar.dateFromFields", "call this.calendar.dateFromFields",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// CalendarDateUntil // CalendarDateUntil
"get this.calendar.dateUntil", "get this.calendar.dateUntil",

View File

@ -14,9 +14,14 @@ features: [Temporal]
const actual = []; const actual = [];
const expected = [ const expected = [
// CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.extra",
"get options.extra", "get options.extra",
// Temporal.Calendar.prototype.dateAdd
"get options.overflow", "get options.overflow",
// overwriting property in custom calendar dateAdd
"getOwnPropertyDescriptor options.overflow",
]; ];
const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options"); const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options");

View File

@ -14,11 +14,17 @@ features: [Temporal]
const actual = []; const actual = [];
const expected = [ const expected = [
// CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.overflow",
"get options.overflow", "get options.overflow",
// Temporal.Calendar.prototype.dateAdd
"get options.overflow", "get options.overflow",
"get options.overflow.toString", "get options.overflow.toString",
"call options.overflow.toString", "call options.overflow.toString",
// overwriting property in custom calendar dateAdd
"getOwnPropertyDescriptor options.overflow",
// Temporal.Calendar.prototype.yearMonthFromFields (toPrimitiveObserver copied but not options object)
"get options.overflow.toString", "get options.overflow.toString",
"call options.overflow.toString", "call options.overflow.toString",
]; ];

View File

@ -60,12 +60,17 @@ const expected = [
"call this.calendar.year", "call this.calendar.year",
"get this.calendar.dateFromFields", "get this.calendar.dateFromFields",
"call this.calendar.dateFromFields", "call this.calendar.dateFromFields",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// CalendarDateUntil // CalendarDateUntil
"get this.calendar.dateUntil", "get this.calendar.dateUntil",

View File

@ -122,12 +122,17 @@ const expectedOpsForCalendarDifference = [
"get other.timeZone[Symbol.toPrimitive]", "get other.timeZone[Symbol.toPrimitive]",
"get other.timeZone.toString", "get other.timeZone.toString",
"call other.timeZone.toString", "call other.timeZone.toString",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// DifferenceZonedDateTime // DifferenceZonedDateTime
"get this.timeZone.getOffsetNanosecondsFor", "get this.timeZone.getOffsetNanosecondsFor",

View File

@ -122,12 +122,17 @@ const expectedOpsForCalendarDifference = [
"get other.timeZone[Symbol.toPrimitive]", "get other.timeZone[Symbol.toPrimitive]",
"get other.timeZone.toString", "get other.timeZone.toString",
"call other.timeZone.toString", "call other.timeZone.toString",
// MergeLargestUnitOption // CopyDataProperties
"ownKeys options", "ownKeys options",
"getOwnPropertyDescriptor options.roundingIncrement",
"get options.roundingIncrement", "get options.roundingIncrement",
"getOwnPropertyDescriptor options.roundingMode",
"get options.roundingMode", "get options.roundingMode",
"getOwnPropertyDescriptor options.largestUnit",
"get options.largestUnit", "get options.largestUnit",
"getOwnPropertyDescriptor options.smallestUnit",
"get options.smallestUnit", "get options.smallestUnit",
"getOwnPropertyDescriptor options.additional",
"get options.additional", "get options.additional",
// DifferenceZonedDateTime // DifferenceZonedDateTime
"get this.timeZone.getOffsetNanosecondsFor", "get this.timeZone.getOffsetNanosecondsFor",