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

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

Issue 1815773002: Remove runtime flags for Proxy and Reflect (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 4 years, 9 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 | « test/mjsunit/harmony/proxies-accesschecks.js ('k') | test/mjsunit/harmony/proxies-bind.js » ('j') | 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 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 // Flags: --harmony-proxies --harmony-reflect
6
7 (function testNonCallable() {
8 var proxy = new Proxy({},{});
9 assertThrows(function(){ proxy() }, TypeError);
10
11 var proxy2 = new Proxy(proxy, {});
12 assertThrows(function(){ proxy2() }, TypeError);
13 })();
14
15 (function testCallProxyFallbackNoArguments() {
16 var called = false;
17 var target = function() {
18 called = true;
19 }
20 var proxy = new Proxy(target, {});
21 assertFalse(called);
22 proxy();
23 assertTrue(called);
24
25 called = false;
26 var proxy2 = new Proxy(proxy, {});
27 assertFalse(called);
28 proxy2();
29 assertTrue(called);
30 })();
31
32 (function testCallProxyFallback1Argument() {
33 var called = false;
34 var target = function(a) {
35 called = true;
36 assertEquals('1', a);
37 }
38 var proxy = new Proxy(target, {});
39 assertFalse(called);
40 proxy('1');
41 assertTrue(called);
42 })();
43
44 (function testCallProxyFallback2Arguments() {
45 var called = false;
46 var target = function(a, b) {
47 called = true;
48 assertEquals('1', a);
49 assertEquals('2', b);
50 }
51 var proxy = new Proxy(target, {});
52 assertFalse(called);
53 proxy('1', '2');
54 assertTrue(called);
55 })();
56
57 (function testCallProxyFallbackChangedReceiver() {
58 var apply_receiver = {receiver:true};
59 var seen_receiver = undefined;
60 var target = function() {
61 seen_receiver = this;
62 }
63 var proxy = new Proxy(target, {});
64 assertEquals(undefined, seen_receiver);
65 Reflect.apply(proxy, apply_receiver, [1,2,3,4]);
66 assertSame(apply_receiver, seen_receiver);
67 })();
68
69 (function testCallProxyTrap() {
70 var called_target = false;
71 var called_handler = false;
72 var target = function(a, b) {
73 called_target = true;
74 assertEquals(1, a);
75 assertEquals(2, b);
76 }
77 var handler = {
78 apply: function(target, this_arg, args) {
79 target.apply(this_arg, args);
80 called_handler = true;
81 }
82 }
83 var proxy = new Proxy(target, handler);
84 assertFalse(called_target);
85 assertFalse(called_handler);
86 Reflect.apply(proxy, {rec:1}, [1,2]);
87 assertTrue(called_target);
88 assertTrue(called_handler);
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 assertThrows(() => {
103 Function.prototype.call.apply(proxy, [null]);
104 }, TypeError);
105 assertThrows(() => {
106 Function.prototype.apply.apply(proxy, [null, []]);
107 }, TypeError);
108
109 var proxy_to_proxy = new Proxy(proxy, { apply() { assertUnreachable(); } });
110 assertThrows(() => { proxy_to_proxy(); }, TypeError);
111 assertThrows(() => { ({ proxy_to_proxy }).proxy_to_proxy(); }, TypeError);
112 assertThrows(() => { Reflect.apply(proxy_to_proxy, null, []); }, TypeError);
113 assertThrows(() => { Reflect.apply(proxy_to_proxy, { proxy }, []); },
114 TypeError);
115 assertThrows(() => {
116 Function.prototype.call.apply(proxy_to_proxy, [null]);
117 }, TypeError);
118 assertThrows(() => {
119 Function.prototype.apply.apply(proxy_to_proxy, [null, []]);
120 }, TypeError);
121 });
122 })();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/proxies-accesschecks.js ('k') | test/mjsunit/harmony/proxies-bind.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698