Debian Codegraph @

js/src/tests/test262/built-ins/Object/keys/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.keys
6 description: >
7 Property names are returned in ascending chronological order of creation
8 that is unaffected by [[DefineOwnProperty]].
9 info: |
10 Object.keys ( O )
11
12 [...]
13 2. Let nameList be ? EnumerableOwnPropertyNames(obj, key).
14 3. Return CreateArrayFromList(nameList).
15
16 EnumerableOwnPropertyNames ( O, kind )
17
18 [...]
19 2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
20 [...]
21
22 OrdinaryOwnPropertyKeys ( O )
23
24 [...]
25 3. For each own property key P of O that is a String but is not an array index,
26 in ascending chronological order of property creation, do
27 a. Add P as the last element of keys.
28 [...]
29 5. Return keys.
30 includes: [compareArray.js]
31 ---*/
32
33 var obj = {};
34 Object.defineProperty(obj, "a", {
35 get: function() {},
36 set: function(_value) {},
37 enumerable: true,
38 configurable: true,
39 });
40 obj.b = 2;
41 Object.defineProperty(obj, "a", {value: 1});
42 assert.compareArray(Object.keys(obj), ["a", "b"]);
43
44 reportCompare(0, 0);