Debian Codegraph @

js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/order-after-define-property.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-object.getownpropertysymbols
6 description: >
7 Property names are returned in ascending chronological order of creation
8 that is unaffected by [[DefineOwnProperty]].
9 info: |
10 Object.getOwnPropertySymbols ( O )
11
12 1. Return ? GetOwnPropertyKeys(O, Symbol).
13
14 GetOwnPropertyKeys ( O, type )
15
16 1. Let obj be ? ToObject(O).
17 2. Let keys be ? obj.[[OwnPropertyKeys]]().
18 [...]
19
20 OrdinaryOwnPropertyKeys ( O )
21
22 [...]
23 4. For each own property key P of O that is a Symbol, in ascending
24 chronological order of property creation, do
25 a. Add P as the last element of keys.
26 5. Return keys.
27 features: [Symbol]
28 includes: [compareArray.js]
29 ---*/
30
31 var symA = Symbol("a");
32 var symB = Symbol("b");
33
34 var obj = {};
35 obj[symA] = 1;
36 obj[symB] = 2;
37 Object.defineProperty(obj, symA, {
38 get: function() {},
39 });
40 assert.compareArray(Object.getOwnPropertySymbols(obj), [symA, symB]);
41
42 var arr = [];
43 arr[symA] = 1;
44 arr[symB] = 2;
45 Object.defineProperty(arr, symA, {writable: false});
46 assert.compareArray(Object.getOwnPropertySymbols(arr), [symA, symB]);
47
48 reportCompare(0, 0);