Debian Codegraph @

js/src/jit-test/tests/proxy/polymorphic-function-closure.js

raw
1 function makeProxy(n) {
2 return new Proxy({}, {
3 get() { return n; }
4 })
5 }
6
7 var arr = [];
8 for (var i = 0; i < 100; i++) {
9 arr.push(makeProxy(i));
10 }
11
12 // Test that proxy get traps with the same script but different
13 // functions call the correct target.
14 for (var i = 0; i < 500; i++) {
15 var idx = i % arr.length;
16 assertEq(arr[idx].x, idx);
17 }