Skip to content

Commit 99bc91e

Browse files
ptomatoMs2ger
authored andcommitted
Temporal: Test change from MergeLargestUnitOption to CopyDataProperties
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.
1 parent dfbeca3 commit 99bc91e

File tree

13 files changed

+74
-8
lines changed

13 files changed

+74
-8
lines changed

harness/temporalHelpers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,10 @@ var TemporalHelpers = {
16121612
calls.push(`ownKeys ${objectName}`);
16131613
return Reflect.ownKeys(target);
16141614
},
1615+
getOwnPropertyDescriptor(target, key) {
1616+
calls.push(`getOwnPropertyDescriptor ${formatPropertyName(key, objectName)}`);
1617+
return Reflect.getOwnPropertyDescriptor(target, key);
1618+
},
16151619
get(target, key, receiver) {
16161620
calls.push(`get ${formatPropertyName(key, objectName)}`);
16171621
const result = Reflect.get(target, key, receiver);

test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ const expected = [
4848
"get options.roundingIncrement",
4949
"get options.roundingIncrement.valueOf",
5050
"call options.roundingIncrement.valueOf",
51-
// MergeLargestUnitOption
51+
// CopyDataProperties
5252
"ownKeys options",
53+
"getOwnPropertyDescriptor options.roundingIncrement",
5354
"get options.roundingIncrement",
55+
"getOwnPropertyDescriptor options.roundingMode",
5456
"get options.roundingMode",
57+
"getOwnPropertyDescriptor options.largestUnit",
5558
"get options.largestUnit",
59+
"getOwnPropertyDescriptor options.smallestUnit",
5660
"get options.smallestUnit",
61+
"getOwnPropertyDescriptor options.additional",
5762
"get options.additional",
5863
// CalendarDateUntil
5964
"get this.calendar.dateUntil",

test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ const expected = [
4848
"get options.roundingIncrement",
4949
"get options.roundingIncrement.valueOf",
5050
"call options.roundingIncrement.valueOf",
51-
// MergeLargestUnitOption
51+
// CopyDataProperties
5252
"ownKeys options",
53+
"getOwnPropertyDescriptor options.roundingIncrement",
5354
"get options.roundingIncrement",
55+
"getOwnPropertyDescriptor options.roundingMode",
5456
"get options.roundingMode",
57+
"getOwnPropertyDescriptor options.largestUnit",
5558
"get options.largestUnit",
59+
"getOwnPropertyDescriptor options.smallestUnit",
5660
"get options.smallestUnit",
61+
"getOwnPropertyDescriptor options.additional",
5762
"get options.additional",
5863
// CalendarDateUntil
5964
"get this.calendar.dateUntil",

test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ const expected = [
6666
"get options.roundingIncrement",
6767
"get options.roundingIncrement.valueOf",
6868
"call options.roundingIncrement.valueOf",
69-
// MergeLargestUnitOption
69+
// CopyDataProperties
7070
"ownKeys options",
71+
"getOwnPropertyDescriptor options.roundingIncrement",
7172
"get options.roundingIncrement",
73+
"getOwnPropertyDescriptor options.roundingMode",
7274
"get options.roundingMode",
75+
"getOwnPropertyDescriptor options.largestUnit",
7376
"get options.largestUnit",
77+
"getOwnPropertyDescriptor options.smallestUnit",
7478
"get options.smallestUnit",
79+
"getOwnPropertyDescriptor options.additional",
7580
"get options.additional",
7681
// CalendarDateUntil
7782
"get this.calendar.dateUntil",

test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ const expected = [
6666
"get options.roundingIncrement",
6767
"get options.roundingIncrement.valueOf",
6868
"call options.roundingIncrement.valueOf",
69-
// MergeLargestUnitOption
69+
// CopyDataProperties
7070
"ownKeys options",
71+
"getOwnPropertyDescriptor options.roundingIncrement",
7172
"get options.roundingIncrement",
73+
"getOwnPropertyDescriptor options.roundingMode",
7274
"get options.roundingMode",
75+
"getOwnPropertyDescriptor options.largestUnit",
7376
"get options.largestUnit",
77+
"getOwnPropertyDescriptor options.smallestUnit",
7478
"get options.smallestUnit",
79+
"getOwnPropertyDescriptor options.additional",
7580
"get options.additional",
7681
// CalendarDateUntil
7782
"get this.calendar.dateUntil",

test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ features: [Temporal]
1414

1515
const actual = [];
1616
const expected = [
17+
// CopyDataProperties
1718
"ownKeys options",
19+
"getOwnPropertyDescriptor options.extra",
1820
"get options.extra",
21+
// Temporal.Calendar.prototype.dateAdd
1922
"get options.overflow",
23+
// overwriting property in custom calendar dateAdd
24+
"getOwnPropertyDescriptor options.overflow",
2025
];
2126
const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options");
2227

test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ features: [Temporal]
1414

1515
const actual = [];
1616
const expected = [
17+
// CopyDataProperties
1718
"ownKeys options",
19+
"getOwnPropertyDescriptor options.overflow",
1820
"get options.overflow",
21+
// Temporal.Calendar.prototype.dateAdd
1922
"get options.overflow",
2023
"get options.overflow.toString",
2124
"call options.overflow.toString",
25+
// overwriting property in custom calendar dateAdd
26+
"getOwnPropertyDescriptor options.overflow",
27+
// Temporal.Calendar.prototype.yearMonthFromFields (toPrimitiveObserver copied but not options object)
2228
"get options.overflow.toString",
2329
"call options.overflow.toString",
2430
];

test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,17 @@ const expected = [
6060
"call this.calendar.year",
6161
"get this.calendar.dateFromFields",
6262
"call this.calendar.dateFromFields",
63-
// MergeLargestUnitOption
63+
// CopyDataProperties
6464
"ownKeys options",
65+
"getOwnPropertyDescriptor options.roundingIncrement",
6566
"get options.roundingIncrement",
67+
"getOwnPropertyDescriptor options.roundingMode",
6668
"get options.roundingMode",
69+
"getOwnPropertyDescriptor options.largestUnit",
6770
"get options.largestUnit",
71+
"getOwnPropertyDescriptor options.smallestUnit",
6872
"get options.smallestUnit",
73+
"getOwnPropertyDescriptor options.additional",
6974
"get options.additional",
7075
// CalendarDateUntil
7176
"get this.calendar.dateUntil",

test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ features: [Temporal]
1414

1515
const actual = [];
1616
const expected = [
17+
// CopyDataProperties
1718
"ownKeys options",
19+
"getOwnPropertyDescriptor options.extra",
1820
"get options.extra",
21+
// Temporal.Calendar.prototype.dateAdd
1922
"get options.overflow",
23+
// overwriting property in custom calendar dateAdd
24+
"getOwnPropertyDescriptor options.overflow",
2025
];
2126
const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options");
2227

test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ features: [Temporal]
1414

1515
const actual = [];
1616
const expected = [
17+
// CopyDataProperties
1718
"ownKeys options",
19+
"getOwnPropertyDescriptor options.overflow",
1820
"get options.overflow",
21+
// Temporal.Calendar.prototype.dateAdd
1922
"get options.overflow",
2023
"get options.overflow.toString",
2124
"call options.overflow.toString",
25+
// overwriting property in custom calendar dateAdd
26+
"getOwnPropertyDescriptor options.overflow",
27+
// Temporal.Calendar.prototype.yearMonthFromFields (toPrimitiveObserver copied but not options object)
2228
"get options.overflow.toString",
2329
"call options.overflow.toString",
2430
];

0 commit comments

Comments
 (0)