1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (C) 2018 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.assign
description: >
Symbol-valued properties are copied after String-valued properties.
info: |
19.1.2.1 Object.assign ( target, ...sources )
...
4. For each element nextSource of sources, in ascending index order, do
a. ...
b. Else,
i. Let from be ! ToObject(nextSource).
ii. Let keys be ? from.[[OwnPropertyKeys]]().
c. For each element nextKey of keys in List order, do
...
...
9.1.11.1 OrdinaryOwnPropertyKeys ( O )
...
3. For each own property key P of O that is a String but is not an integer index,
in ascending chronological order of property creation, do
a. Add P as the last element of keys.
4. For each own property key P of O that is a Symbol, in ascending chronological
order of property creation, do
a. Add P as the last element of keys.
...
includes: [compareArray.js]
---*/
var log = [];
var sym1 = Symbol("x");
var sym2 = Symbol("y");
var source = {};
Object.defineProperty(source, sym1, {
get: function(){ log.push("get sym(x)") },
enumerable: true, configurable: true,
});
Object.defineProperty(source, "a", {
get: function(){ log.push("get a") },
enumerable: true, configurable: true,
});
Object.defineProperty(source, sym2, {
get: function(){ log.push("get sym(y)") },
enumerable: true, configurable: true,
});
Object.defineProperty(source, "b", {
get: function(){ log.push("get b") },
enumerable: true, configurable: true,
});
var target = Object.assign({}, source);
assert.compareArray(log, ["get a", "get b", "get sym(x)", "get sym(y)"]);
reportCompare(0, 0);
|