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

Unified Diff: test/mjsunit/harmony/proxies-call.js

Issue 1499593003: [runtime] [proxy] Implementing [[Call]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding dcheck 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 side-by-side diff with in-line comments
Download patch
« src/runtime/runtime-proxy.cc ('K') | « src/x87/builtins-x87.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/proxies-call.js
diff --git a/test/mjsunit/harmony/proxies-call.js b/test/mjsunit/harmony/proxies-call.js
new file mode 100644
index 0000000000000000000000000000000000000000..2f69ea79085be0e228160e34321c6fa48ee4a282
--- /dev/null
+++ b/test/mjsunit/harmony/proxies-call.js
@@ -0,0 +1,85 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-proxies --harmony-reflect
+
+(function testNonCallable() {
+ var proxy = new Proxy({},{});
+ assertThrows(function(){ proxy() }, TypeError);
+
+ var proxy2 = new Proxy(proxy, {});
+ assertThrows(function(){ proxy2() }, TypeError);
+})();
+
+(function testCallProxyFallbackNoArguments() {
+ var called = false;
+ var target = function() {
+ called = true;
+ }
+ var proxy = new Proxy(target, {});
+ assertFalse(called);
+ proxy();
+ assertTrue(called);
+
+ called = false;
+ var proxy2 = new Proxy(proxy, {});
+ assertFalse(called);
+ proxy2();
+ assertTrue(called);
+})();
+
+(function testCallProxyFallback1Argument() {
+ var called = false;
+ var target = function(a) {
+ called = true;
+ assertEquals('1', a);
+ }
+ var proxy = new Proxy(target, {});
+ assertFalse(called);
+ proxy('1');
+ assertTrue(called);
+})();
+
+(function testCallProxyFallback2Arguments() {
+ var called = false;
+ var target = function(a, b) {
+ called = true;
+ assertEquals('1', a);
+ assertEquals('2', b);
+ }
+ var proxy = new Proxy(target, {});
+ assertFalse(called);
+ proxy('1', '2');
+ assertTrue(called);
+})();
+
+(function testCallProxyFallbackChangedReceiver() {
+ var apply_receiver = {receiver:true};
+ var seen_receiver = undefined;
+ var target = function() {
+ seen_receiver = this;
Jakob Kummerow 2015/12/07 15:55:08 super-nit: s/ / /
+ }
+ var proxy = new Proxy(target, {});
+ assertEquals(undefined, seen_receiver);
+ Reflect.apply(proxy, apply_receiver , [1,2,3,4]);
Jakob Kummerow 2015/12/07 15:55:08 nit: s/ ,/,/
+ assertSame(apply_receiver, seen_receiver);
+})();
+
+(function testCallProxyTrap() {
+ var called = false;
+ var target = function(a, b) {
+ called = true;
+ assertEquals(1, a);
+ assertEquals(2, b);
+ }
+ var handler = {
+ apply : function(target, this_arg, args) {
+ target.apply(this_arg, args);
Jakob Kummerow 2015/12/07 15:55:08 You probably want to check that this, too, was cal
Camillo Bruni 2015/12/07 16:54:10 added called_target and called_handler
+ }
+ }
+ var proxy = new Proxy(target, handler);
+ assertFalse(called);
+ Reflect.apply(proxy, {rec:1}, [1,2,3,4]);
Jakob Kummerow 2015/12/07 15:55:08 I'd align the arguments with the assertEquals() in
Camillo Bruni 2015/12/07 16:54:10 right.
+ assertTrue(called);
+})();
« src/runtime/runtime-proxy.cc ('K') | « src/x87/builtins-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698