mirror of https://github.com/tc39/test262.git
Temporal: Test Calendar.p.mergeFields enumeration changes
This tests 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 the Temporal.Calendar.prototype.mergeFields method. Due to the use of the pre-existing spec operation CopyDataProperties, now symbol keys are merged into the return value, and 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 commit is contained in:
parent
99bc91e0f5
commit
b5d3192914
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.calendar.prototype.mergefields
|
esid: sec-temporal.calendar.prototype.mergefields
|
||||||
description: Only string keys from the arguments are merged
|
description: Both string and symbol keys from the arguments are merged
|
||||||
info: |
|
info: |
|
||||||
1. Let calendar be the this value.
|
1. Let calendar be the this value.
|
||||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||||
|
@ -50,6 +50,6 @@ const foo = Symbol("foo");
|
||||||
const bar = Symbol("bar");
|
const bar = Symbol("bar");
|
||||||
assertEntriesEqual(
|
assertEntriesEqual(
|
||||||
cal.mergeFields({ [foo]: 1 }, { [bar]: 2 }),
|
cal.mergeFields({ [foo]: 1 }, { [bar]: 2 }),
|
||||||
[],
|
[[foo, 1], [bar, 2]],
|
||||||
"symbol keys are not merged"
|
"symbol keys are also merged"
|
||||||
);
|
);
|
||||||
|
|
45
test/built-ins/Temporal/Calendar/prototype/mergeFields/order-of-operations.js
vendored
Normal file
45
test/built-ins/Temporal/Calendar/prototype/mergeFields/order-of-operations.js
vendored
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright (C) 2022 Igalia S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.calendar.prototype.mergefields
|
||||||
|
description: Properties on objects passed to mergeFields() are accessed in the correct order
|
||||||
|
features: [Temporal]
|
||||||
|
includes: [compareArray.js, temporalHelpers.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const expected = [
|
||||||
|
"ownKeys fields",
|
||||||
|
"getOwnPropertyDescriptor fields.year",
|
||||||
|
"get fields.year",
|
||||||
|
"getOwnPropertyDescriptor fields.month",
|
||||||
|
"get fields.month",
|
||||||
|
"getOwnPropertyDescriptor fields.day",
|
||||||
|
"get fields.day",
|
||||||
|
"getOwnPropertyDescriptor fields.extra",
|
||||||
|
"get fields.extra",
|
||||||
|
"ownKeys additionalFields",
|
||||||
|
"getOwnPropertyDescriptor additionalFields.3",
|
||||||
|
"get additionalFields.3",
|
||||||
|
"getOwnPropertyDescriptor additionalFields.monthCode",
|
||||||
|
"get additionalFields.monthCode",
|
||||||
|
"getOwnPropertyDescriptor additionalFields[Symbol('extra')]",
|
||||||
|
"get additionalFields[Symbol('extra')]",
|
||||||
|
];
|
||||||
|
const actual = [];
|
||||||
|
|
||||||
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
|
year: 2022,
|
||||||
|
month: 10,
|
||||||
|
day: 17,
|
||||||
|
extra: "extra property",
|
||||||
|
}, "fields");
|
||||||
|
const additionalFields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
|
[Symbol("extra")]: "extra symbol property",
|
||||||
|
monthCode: "M10",
|
||||||
|
3: "extra array index property",
|
||||||
|
}, "additionalFields");
|
||||||
|
|
||||||
|
const instance = new Temporal.Calendar("iso8601");
|
||||||
|
instance.mergeFields(fields, additionalFields);
|
||||||
|
assert.compareArray(actual, expected, "order of observable operations");
|
Loading…
Reference in New Issue