From 78bd8b44326120ddc4788e7008f1c70fe140fbe4 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Sun, 22 Jul 2018 22:03:12 +0300 Subject: [PATCH] Testcase additions for recursive Proxies --- .../test-bi-proxy-handler-proxy-1.js | 28 +++++++++++++++++++ .../test-bi-proxy-handler-proxy-2.js | 17 +++++++++++ .../test-bi-proxy-target-proxy-1.js | 25 +++++++++++++++++ .../test-bi-proxy-target-proxy-2.js | 11 ++++++++ 4 files changed, 81 insertions(+) create mode 100644 tests/ecmascript/test-bi-proxy-handler-proxy-1.js create mode 100644 tests/ecmascript/test-bi-proxy-handler-proxy-2.js create mode 100644 tests/ecmascript/test-bi-proxy-target-proxy-1.js create mode 100644 tests/ecmascript/test-bi-proxy-target-proxy-2.js diff --git a/tests/ecmascript/test-bi-proxy-handler-proxy-1.js b/tests/ecmascript/test-bi-proxy-handler-proxy-1.js new file mode 100644 index 0000000000..fb8df2ddc1 --- /dev/null +++ b/tests/ecmascript/test-bi-proxy-handler-proxy-1.js @@ -0,0 +1,28 @@ +/*=== +P1.get called true get true +get called true foo true +<<>> +P1.get called true get true +get called true bar true +<<>> +===*/ + +var T1 = {}; +var P1 = new Proxy(T1, { + get: function (targ, prop, recv) { + print('P1.get called', targ === T1, prop, recv === P1); + + if (prop === 'get') { + return function (targ, prop, recv) { + print('get called', targ === T2, prop, recv === P2); + return '<<<' + prop + '>>>' + }; + } + } +}); + +var T2 = {}; +var P2 = new Proxy(T2, P1); + +print(P2.foo); +print(P2.bar); diff --git a/tests/ecmascript/test-bi-proxy-handler-proxy-2.js b/tests/ecmascript/test-bi-proxy-handler-proxy-2.js new file mode 100644 index 0000000000..8a1cd88e47 --- /dev/null +++ b/tests/ecmascript/test-bi-proxy-handler-proxy-2.js @@ -0,0 +1,17 @@ +/*=== +P1.get called foo +aiee +===*/ + +var curr = { + get: function (targ, prop, recv) { + print('P1.get called', prop); + return 'aiee'; + } +}; +for (var i = 0; i < 1e6; i++) { + curr = new Proxy(curr, {}); +} + +var finalProxy = new Proxy({}, curr); +print(finalProxy.foo); diff --git a/tests/ecmascript/test-bi-proxy-target-proxy-1.js b/tests/ecmascript/test-bi-proxy-target-proxy-1.js new file mode 100644 index 0000000000..da06b9befd --- /dev/null +++ b/tests/ecmascript/test-bi-proxy-target-proxy-1.js @@ -0,0 +1,25 @@ +/*=== +bar +undefined +true +false +123 +true +undefined +true +===*/ + +var A = { foo: 'bar' }; +var P1 = new Proxy(A, {}); +var P2 = new Proxy(P1, {}); +var P3 = new Proxy(P2, {}); + +print(P3.foo); +print(P3.bar); +print('foo' in P3); +print('bar' in P3); +P3.quux = 123; +print(A.quux); +print(delete P3.quux); +print(A.quux); +print(delete P3.noSuch); diff --git a/tests/ecmascript/test-bi-proxy-target-proxy-2.js b/tests/ecmascript/test-bi-proxy-target-proxy-2.js new file mode 100644 index 0000000000..db4ea28289 --- /dev/null +++ b/tests/ecmascript/test-bi-proxy-target-proxy-2.js @@ -0,0 +1,11 @@ +/*=== +123 +===*/ + +var curr = { foo: 123 }; +for (var i = 0; i < 1e6; i++) { + curr = new Proxy(curr, {}); +} + +var finalProxy = curr; +print(finalProxy.foo);