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}`);
return Reflect.ownKeys(target);
},
getOwnPropertyDescriptor(target, key) {
calls.push(`getOwnPropertyDescriptor ${formatPropertyName(key, objectName)}`);
return Reflect.getOwnPropertyDescriptor(target, key);
},
get(target, key, receiver) {
calls.push(`get ${formatPropertyName(key, objectName)}`);
const result = Reflect.get(target, key, receiver);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,11 +14,17 @@ features: [Temporal]
const actual = [];
const expected = [
// CopyDataProperties
"ownKeys options",
"getOwnPropertyDescriptor options.overflow",
"get options.overflow",
// Temporal.Calendar.prototype.dateAdd
"get options.overflow",
"get 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",
"call options.overflow.toString",
];

View File

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

View File

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

View File

@ -14,11 +14,17 @@ features: [Temporal]
const actual = [];
const expected = [
// CopyDataProperties
"ownKeys options",
"getOwnPropertyDescriptor options.overflow",
"get options.overflow",
// Temporal.Calendar.prototype.dateAdd
"get options.overflow",
"get 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",
"call options.overflow.toString",
];

View File

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

View File

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

View File

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