Skip to content

Commit ded17b0

Browse files
committed
Temporal: Test Calendar.p.mergeFields enumeration changes
This tests the normative changes in tc39/proposal-temporal#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.
1 parent 0182063 commit ded17b0

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

test/built-ins/Temporal/Calendar/prototype/mergeFields/non-string-properties.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/*---
66
esid: sec-temporal.calendar.prototype.mergefields
7-
description: Only string keys from the arguments are merged
7+
description: Both string and symbol keys from the arguments are merged
88
info: |
99
1. Let calendar be the this value.
1010
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
@@ -48,6 +48,6 @@ const foo = Symbol("foo");
4848
const bar = Symbol("bar");
4949
assertEntriesEqual(
5050
cal.mergeFields({ [foo]: 1 }, { [bar]: 2 }),
51-
[],
52-
"symbol keys are not merged"
51+
[[foo, 1], [bar, 2]],
52+
"symbol keys are also merged"
5353
);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (C) 2022 Igalia S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.calendar.prototype.mergefields
6+
description: Properties on objects passed to mergeFields() are accessed in the correct order
7+
features: [Temporal]
8+
includes: [compareArray.js, temporalHelpers.js]
9+
---*/
10+
11+
const expected = [
12+
"ownKeys fields",
13+
"getOwnPropertyDescriptor fields.year",
14+
"get fields.year",
15+
"getOwnPropertyDescriptor fields.month",
16+
"get fields.month",
17+
"getOwnPropertyDescriptor fields.day",
18+
"get fields.day",
19+
"getOwnPropertyDescriptor fields.extra",
20+
"get fields.extra",
21+
"ownKeys additionalFields",
22+
"getOwnPropertyDescriptor additionalFields.3",
23+
"get additionalFields.3",
24+
"getOwnPropertyDescriptor additionalFields.monthCode",
25+
"get additionalFields.monthCode",
26+
"getOwnPropertyDescriptor additionalFields[Symbol('extra')]",
27+
"get additionalFields[Symbol('extra')]",
28+
];
29+
const actual = [];
30+
31+
const fields = TemporalHelpers.propertyBagObserver(actual, {
32+
year: 2022,
33+
month: 10,
34+
day: 17,
35+
extra: "extra property",
36+
}, "fields");
37+
const additionalFields = TemporalHelpers.propertyBagObserver(actual, {
38+
[Symbol("extra")]: "extra symbol property",
39+
monthCode: "M10",
40+
3: "extra array index property",
41+
}, "additionalFields");
42+
43+
const instance = new Temporal.Calendar("iso8601");
44+
instance.mergeFields(fields, additionalFields);
45+
assert.compareArray(actual, expected, "order of observable operations");

0 commit comments

Comments
 (0)