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

Side by Side Diff: test/mjsunit/harmony/reflect-enumerate-opt.js

Issue 1721453002: Remove Reflect.enumerate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: private symbols passes Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2015 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 // This is adapted from mjsunit/for-in-opt.js.
6
7 // Flags: --harmony-proxies --harmony-reflect --allow-natives-syntax
8
9
10 "use strict";
11
12 function f(o) {
13 var result = [];
14 for (var i of Reflect.enumerate(Object(o))) {
15 result.push(i);
16 }
17 return result;
18 }
19
20 assertEquals(["0"], f("a"));
21 assertEquals(["0"], f("a"));
22 %OptimizeFunctionOnNextCall(f);
23 assertEquals(["0","1","2"], f("bla"));
24
25 // Test the lazy deopt points.
26 var keys = ["a", "b", "c", "d"];
27 var has_keys = [];
28 var deopt_has = false;
29 var deopt_enum = false;
30
31 var handler = {
32 enumerate: function(target) {
33 if (deopt_enum) {
34 %DeoptimizeFunction(f2);
35 deopt_enum = false;
36 }
37 return keys;
38 },
39
40 getPropertyDescriptor: function(k) {
41 if (deopt_has) {
42 %DeoptimizeFunction(f2);
43 deopt_has = false;
44 }
45 has_keys.push(k);
46 return {value: 10, configurable: true, writable: false, enumerable: true};
47 }
48 };
49
50 // TODO(neis,cbruni): Enable once the enumerate proxy trap is properly
51 // implemented.
52 // var proxy = new Proxy({}, handler);
53 // var o = {__proto__: proxy};
54 //
55 // function f2(o) {
56 // var result = [];
57 // for (var i of Reflect.enumerate(o)) {
58 // result.push(i);
59 // }
60 // return result;
61 // }
62 //
63 // function check_f2() {
64 // assertEquals(keys, f2(o));
65 // assertEquals(keys, has_keys);
66 // has_keys.length = 0;
67 // }
68 //
69 // check_f2();
70 // check_f2();
71 // Test lazy deopt after ForInEnumerate
72 // %OptimizeFunctionOnNextCall(f2);
73 // deopt_enum = true;
74 // check_f2();
75 // Test lazy deopt after FILTER_KEY
76 // %OptimizeFunctionOnNextCall(f2);
77 // deopt_has = true;
78 // check_f2();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/reflect-enumerate-delete.js ('k') | test/mjsunit/harmony/reflect-enumerate-special-cases.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698