OLD | NEW |
---|---|
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 --harmony-reflect | 5 // Flags: --harmony-proxies --harmony-reflect |
6 | 6 |
7 (function testNonCallable() { | 7 (function testNonCallable() { |
8 var proxy = new Proxy({},{}); | 8 var proxy = new Proxy({},{}); |
9 assertThrows(function(){ proxy() }, TypeError); | 9 assertThrows(function(){ proxy() }, TypeError); |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 called_handler = true; | 80 called_handler = true; |
81 } | 81 } |
82 } | 82 } |
83 var proxy = new Proxy(target, handler); | 83 var proxy = new Proxy(target, handler); |
84 assertFalse(called_target); | 84 assertFalse(called_target); |
85 assertFalse(called_handler); | 85 assertFalse(called_handler); |
86 Reflect.apply(proxy, {rec:1}, [1,2]); | 86 Reflect.apply(proxy, {rec:1}, [1,2]); |
87 assertTrue(called_target); | 87 assertTrue(called_target); |
88 assertTrue(called_handler); | 88 assertTrue(called_handler); |
89 })(); | 89 })(); |
90 | |
91 | |
92 (function testCallProxyNonCallableTarget() { | |
93 var values = [NaN, 1.5, 100, /RegExp/, "string", {}, [], Symbol(), | |
94 new Map(), new Set(), new WeakMap(), new WeakSet()]; | |
95 values.forEach(target => { | |
96 target = Object(target); | |
97 var proxy = new Proxy(target, { apply() { assertUnreachable(); } }); | |
98 assertThrows(() => { proxy(); }, TypeError); | |
99 assertThrows(() => { ({ proxy }).proxy(); }, TypeError); | |
100 assertThrows(() => { Reflect.apply(proxy, null, []); }, TypeError); | |
101 assertThrows(() => { Reflect.apply(proxy, { proxy }, []); }, TypeError); | |
102 | |
103 var proxy_to_proxy = new Proxy(proxy, { apply() { assertUnreachable(); } }); | |
104 assertThrows(() => { proxy_to_proxy(); }, TypeError); | |
105 assertThrows(() => { ({ proxy_to_proxy }).proxy_to_proxy(); }, TypeError); | |
106 assertThrows(() => { Reflect.apply(proxy_to_proxy, null, []); }, TypeError); | |
107 assertThrows(() => { Reflect.apply(proxy_to_proxy, { proxy }, []); }, | |
108 TypeError); | |
109 }); | |
110 })(); | |
Camillo Bruni
2016/03/02 17:41:03
silly that we forgot this case :)
| |
OLD | NEW |