Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: test/mjsunit/regress/regress-705-shadowed_properties.js

Issue 1612413003: Reland of [runtime] Do not use the enum-cache for non-prototype objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function allKeys(object) {
6 var keys = [];
7 for (var key in object) {
8 keys.push(key);
9 }
10 return keys;
11 }
12
13 var a = { a1: true, a2: true};
14 var b = { b1: true, b2: true};
15 a.__proto__ = b;
16
17 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
18 assertEquals(['b1', 'b2'], allKeys(b));
19
20 // Adding a non-enumerable property to either a or b shouldn't change
21 // the result.
22 var propertyDescriptor = {
23 enumerable: false,
24 configurable: true,
25 writable: true,
26 value: true
27 };
28
29 Object.defineProperty(a, 'a3', propertyDescriptor);
30 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
31 assertEquals(['b1', 'b2'], allKeys(b));
32
33 Object.defineProperty(b, 'b3', propertyDescriptor);
34 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
35 assertEquals(['b1', 'b2'], allKeys(b));
36
37 // A non-enumerable property shadows an enumerable version on the prototype
38 // chain.
39 b['a3'] = true;
40 assertEquals(['a1', 'a2', 'b1', 'b2'], allKeys(a));
41 assertEquals(['b1', 'b2', 'a3'], allKeys(b));
42
43 // Try the same with indexed-properties.
44 var aIndex = {0:true, 1:true};
45 var bIndex = {10:true, 11:true};
46 aIndex.__proto__= bIndex;
47 assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
48 assertEquals(['10', '11'], allKeys(bIndex));
49
50 Object.defineProperty(aIndex, 2, propertyDescriptor);
51 Object.defineProperty(bIndex, 12, propertyDescriptor);
52 assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
53 assertEquals(['10', '11'], allKeys(bIndex));
54
55 bIndex[2] = 2;
56 assertEquals(['0', '1', '10', '11'], allKeys(aIndex));
57 assertEquals(['2', '10', '11'], allKeys(bIndex));
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698