js/src/jit-test/tests/debug/Environment-identity-02.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:0f9599858489
1 // frame.environment is different for different activations of a scope.
2
3 var g = newGlobal();
4 var dbg = Debugger(g);
5 g.eval("function h() { debugger; }");
6 var arr;
7 dbg.onDebuggerStatement = function (hframe) {
8 var e = hframe.older.environment;
9 assertEq(arr.indexOf(e), -1);
10 arr.push(e);
11 };
12
13 function test(code, expectedHits) {
14 arr = [];
15 g.eval(code);
16 assertEq(arr.length, expectedHits);
17 }
18
19 // two separate calls to a function
20 test("(function () { var f = function (a) { h(); return a; }; f(1); f(2); })();", 2);
21
22 // recursive calls to a function
23 test("(function f(n) { h(); return n < 2 ? 1 : n * f(n - 1); })(3);", 3);
24
25 // separate visits to a block in the same call frame
26 test("(function () { for (var i = 0; i < 3; i++) { let j = i * 4; h(); }})();", 3);
27
28 // two strict direct eval calls in the same function scope
29 test("(function () { 'use strict'; for (var i = 0; i < 3; i++) eval('h();'); })();", 3);

mercurial