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

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

Issue 1517463002: [runtime] [proxies] adding tests for uncovered branches (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: dropping mips changes Created 5 years 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
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-proxies 5 // Flags: --harmony-proxies
6 6
7 var target = { 7 var target = {
8 "target_one": 1 8 "target_one": 1
9 }; 9 };
10 target.__proto__ = { 10 target.__proto__ = {
(...skipping 19 matching lines...) Expand all
30 function TestForIn(receiver, expected) { 30 function TestForIn(receiver, expected) {
31 var result = []; 31 var result = [];
32 for (var k in receiver) { 32 for (var k in receiver) {
33 result.push(k); 33 result.push(k);
34 } 34 }
35 assertEquals(expected, result); 35 assertEquals(expected, result);
36 } 36 }
37 37
38 TestForIn(proxy, ["foo", "bar"]); 38 TestForIn(proxy, ["foo", "bar"]);
39 39
40 // Test revoked proxy.
41 var pair = Proxy.revocable(target, handler);
42 TestForIn(pair.proxy, ["foo", "bar"]);
43 pair.revoke();
44 assertThrows(()=>{ TestForIn(pair.proxy, ["foo", "bar"]) }, TypeError);
45
40 // Properly call traps on proxies on the prototype chain. 46 // Properly call traps on proxies on the prototype chain.
41 var receiver = { 47 var receiver = {
42 "receiver_one": 1 48 "receiver_one": 1
43 }; 49 };
44 receiver.__proto__ = proxy; 50 receiver.__proto__ = proxy;
45 TestForIn(receiver, ["receiver_one", "foo", "bar"]); 51 TestForIn(receiver, ["receiver_one", "foo", "bar"]);
46 52
47 // Fall through to default behavior when trap is undefined. 53 // Fall through to default behavior when trap is undefined.
48 handler.enumerate = undefined; 54 handler.enumerate = undefined;
49 TestForIn(proxy, ["target_one", "target_two"]); 55 TestForIn(proxy, ["target_one", "target_two"]);
50 delete handler.enumerate; 56 delete handler.enumerate;
51 TestForIn(proxy, ["target_one", "target_two"]); 57 TestForIn(proxy, ["target_one", "target_two"]);
52 58
53 // Non-string keys must be filtered. 59 // Non-string keys must be filtered.
54 function TestNonStringKey(key) { 60 function TestNonStringKey(key) {
55 handler.enumerate = function(target) { 61 handler.enumerate = function(target) {
56 function* keys() { yield key; } 62 function* keys() { yield key; }
57 return keys(); 63 return keys();
58 } 64 }
59 assertThrows("for (var k in proxy) {}", TypeError); 65 assertThrows("for (var k in proxy) {}", TypeError);
60 } 66 }
61 67
62 TestNonStringKey(1); 68 TestNonStringKey(1);
63 TestNonStringKey(3.14); 69 TestNonStringKey(3.14);
64 TestNonStringKey(Symbol("foo")); 70 TestNonStringKey(Symbol("foo"));
65 TestNonStringKey({bad: "value"}); 71 TestNonStringKey({bad: "value"});
66 TestNonStringKey(null); 72 TestNonStringKey(null);
67 TestNonStringKey(undefined); 73 TestNonStringKey(undefined);
68 TestNonStringKey(true); 74 TestNonStringKey(true);
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/proxies-define-property.js ('k') | test/mjsunit/harmony/proxies-set-prototype-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698