-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testcase additions for recursive Proxies
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |