Debian Codegraph @

js/src/tests/test262/built-ins/Object/assign/strings-and-symbol-order.js

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