From 99bc91e0f5c3bf86f8d559250ed83bdb194a6a91 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 17 Oct 2022 17:37:39 -0700 Subject: [PATCH] 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. --- harness/temporalHelpers.js | 4 ++++ .../PlainDate/prototype/since/order-of-operations.js | 7 ++++++- .../PlainDate/prototype/until/order-of-operations.js | 7 ++++++- .../PlainDateTime/prototype/since/order-of-operations.js | 7 ++++++- .../PlainDateTime/prototype/until/order-of-operations.js | 7 ++++++- .../prototype/add/calendar-arguments-extra-options.js | 5 +++++ .../PlainYearMonth/prototype/add/calendar-arguments.js | 6 ++++++ .../PlainYearMonth/prototype/since/order-of-operations.js | 7 ++++++- .../prototype/subtract/calendar-arguments-extra-options.js | 5 +++++ .../prototype/subtract/calendar-arguments.js | 6 ++++++ .../PlainYearMonth/prototype/until/order-of-operations.js | 7 ++++++- .../ZonedDateTime/prototype/since/order-of-operations.js | 7 ++++++- .../ZonedDateTime/prototype/until/order-of-operations.js | 7 ++++++- 13 files changed, 74 insertions(+), 8 deletions(-) diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index 195245c6c1d..cbfbd555b8c 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -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); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js index f46668f342e..55db1ee449d 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js @@ -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", diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js index 3eda54a42b7..3950b8dfbb2 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js @@ -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", diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js index d5677432779..b73f5a5645d 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js @@ -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", diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js index 55af95484a3..7c61f28536a 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js @@ -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", diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js index 716192590a0..73786913835 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js index a33f4951302..e8d97940e79 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js @@ -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", ]; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js index 59ef87d7c77..2dfe79c95d4 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js @@ -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", diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js index 8243232a0fe..fed109d70a5 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js @@ -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"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js index f594f3806b3..5c196c0e89e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js @@ -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", ]; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js index 07b4e4e3184..ea17c611d3a 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js @@ -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", diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js index 618e129848c..40c8c606e2f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js @@ -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", diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js index ea5f2e797f6..d24cf570caa 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js @@ -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",