Debian Codegraph @

js/src/tests/test262/built-ins/Object/getOwnPropertyDescriptors/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.getownpropertydescriptors
6 description: >
7 Property names are returned in ascending chronological order of creation
8 that is unaffected by [[DefineOwnProperty]].
9 info: |
10 Object.getOwnPropertyDescriptors ( O )
11
12 [...]
13 2. Let ownKeys be ? obj.[[OwnPropertyKeys]]().
14 3. Let descriptors be ! OrdinaryObjectCreate(%Object.prototype%).
15 4. For each element key of ownKeys in List order, do
16 [...]
17 c. If descriptor is not undefined,
18 perform ! CreateDataPropertyOrThrow(descriptors, key, descriptor).
19 5. Return descriptors.
20
21 OrdinaryOwnPropertyKeys ( O )
22
23 [...]
24 3. For each own property key P of O that is a String but is not an array 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
28 chronological order of property creation, do
29 a. Add P as the last element of keys.
30 5. Return keys.
31 features: [Symbol, Reflect]
32 includes: [compareArray.js]
33 ---*/
34
35 var obj = {};
36 var symA = Symbol("a");
37 var symB = Symbol("b");
38 obj[symA] = 1;
39 obj[symB] = 2;
40 Object.defineProperty(obj, symA, {configurable: false});
41 var objDescs = Object.getOwnPropertyDescriptors(obj);
42 assert.compareArray(Reflect.ownKeys(objDescs), [symA, symB]);
43
44 var re = /(?:)/g;
45 re.a = 1;
46 Object.defineProperty(re, "lastIndex", {value: 2});
47 var reDescs = Object.getOwnPropertyDescriptors(re);
48 assert.compareArray(Reflect.ownKeys(reDescs), ["lastIndex", "a"]);
49
50 reportCompare(0, 0);