Skip to content

Commit

Permalink
Testcase additions for recursive Proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
svaarala committed Aug 6, 2018
1 parent d42117f commit 78bd8b4
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/ecmascript/test-bi-proxy-handler-proxy-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*===
P1.get called true get true
get called true foo true
<<<foo>>>
P1.get called true get true
get called true bar true
<<<bar>>>
===*/

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);
17 changes: 17 additions & 0 deletions tests/ecmascript/test-bi-proxy-handler-proxy-2.js
Original file line number Diff line number Diff line change
@@ -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);
25 changes: 25 additions & 0 deletions tests/ecmascript/test-bi-proxy-target-proxy-1.js
Original file line number Diff line number Diff line change
@@ -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);
11 changes: 11 additions & 0 deletions tests/ecmascript/test-bi-proxy-target-proxy-2.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 78bd8b4

Please sign in to comment.