Skip to content

Commit

Permalink
Temporal: Test change from MergeLargestUnitOption to CopyDataProperties
Browse files Browse the repository at this point in the history
This tests some of the normative changes in
tc39/proposal-temporal#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.
  • Loading branch information
ptomato authored and Ms2ger committed Oct 20, 2022
1 parent dfbeca3 commit 99bc91e
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 8 deletions.
4 changes: 4 additions & 0 deletions harness/temporalHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 99bc91e

Please sign in to comment.