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

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

Issue 1499593003: [runtime] [proxy] Implementing [[Call]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updating comment 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
« no previous file with comments | « 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-apply.js
diff --git a/test/mjsunit/harmony/proxies-apply.js b/test/mjsunit/harmony/proxies-apply.js
new file mode 100644
index 0000000000000000000000000000000000000000..4ddffe73b80e985f4f83feb2736ec6c8372f6c1c
--- /dev/null
+++ b/test/mjsunit/harmony/proxies-apply.js
@@ -0,0 +1,89 @@
+// 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;
+ }
+ var proxy = new Proxy(target, {});
+ assertEquals(undefined, seen_receiver);
+ Reflect.apply(proxy, apply_receiver, [1,2,3,4]);
+ assertSame(apply_receiver, seen_receiver);
+})();
+
+(function testCallProxyTrap() {
+ var called_target = false;
+ var called_handler = false;
+ var target = function(a, b) {
+ called_target = true;
+ assertEquals(1, a);
+ assertEquals(2, b);
+ }
+ var handler = {
+ apply: function(target, this_arg, args) {
+ target.apply(this_arg, args);
+ called_handler = true;
+ }
+ }
+ var proxy = new Proxy(target, handler);
+ assertFalse(called_target);
+ assertFalse(called_handler);
+ Reflect.apply(proxy, {rec:1}, [1,2]);
+ assertTrue(called_target);
+ assertTrue(called_handler);
+})();
« no previous file with comments | « src/x87/builtins-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698