Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/entries/getter-making-future-key-nonenumerable.js

raw
1 // Copyright (C) 2015 Jordan Harband. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-object.entries
6 description: Object.entries does not see an element made non-enumerable by a getter that is hit during iteration
7 author: Jordan Harband
8 ---*/
9
10 var bDeletesC = {
11 a: 'A',
12 get b() {
13 Object.defineProperty(this, 'c', {
14 enumerable: false
15 });
16 return 'B';
17 },
18 c: 'C'
19 };
20
21 var result = Object.entries(bDeletesC);
22
23 assert.sameValue(Array.isArray(result), true, 'result is an array');
24 assert.sameValue(result.length, 2, 'result has 2 items');
25
26 assert.sameValue(Array.isArray(result[0]), true, 'first entry is an array');
27 assert.sameValue(Array.isArray(result[1]), true, 'second entry is an array');
28
29 assert.sameValue(result[0][0], 'a', 'first entry has key "a"');
30 assert.sameValue(result[0][1], 'A', 'first entry has value "A"');
31 assert.sameValue(result[1][0], 'b', 'second entry has key "b"');
32 assert.sameValue(result[1][1], 'B', 'second entry has value "B"');