Debian Codegraph @

js/src/jit-test/tests/ion/iterator-indices-3.js

raw
1 function test(o, deleter) {
2 var result = 0;
3 for (var s in o) {
4 if (!o.hasOwnProperty(s)) { continue; }
5 result += o[s];
6 deleter(o);
7 }
8 return result;
9 }
10
11 with ({}) {}
12
13 // Ion-compile |test| with a megamorphic getprop and a generic call.
14 for (var i = 0; i < 2000; i++) {
15 var obj = {};
16 obj["x" + i] = 1;
17 test(obj, () => 1);
18 test(obj, () => 2);
19 }
20
21 assertEq(test({x: 1, y: 2}, (o) => delete o.y), 1);
22 assertEq(test([1,2], (o) => delete o[1]), 1);
23 assertEq(test([1,2], (o) => {o.length = 0}), 1);
24
25 assertEq(test({x: 1, y: 2, z: 3}, (o) => delete o.y), 4);
26 assertEq(test([1,2,3], (o) => delete o[1]), 4);
27 assertEq(test([1,2,3,4], (o) => {o.length = 2}), 3);
28
29 assertEq(test({x: 1, y: 2, z: 3}, (o) => delete o.x), 6);
30 assertEq(test([1,2,3], (o) => delete o[0]), 6);
31 assertEq(test([1], (o) => {o.length = 0}), 1);