summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Debugger-findScripts-ghost.js
blob: c20e5ac1cc37ad5d1a52e2da94e8441514a3abd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// |jit-test| skip-if: isLcovEnabled()

var g = newGlobal({newCompartment: true});
var dbg = new Debugger(g);

g.eval(`
function f(
  a = (
    b = (
      c = function g() {
      },
    ) => {
    },
    d = (
      e = (
        f = (
        ) => {
        },
      ) => {
      },
    ) => {
    },
  ) => {
  },
) {
}
`);

// Debugger shouldn't find ghost functions.
var allScripts = dbg.findScripts();
assertEq(allScripts.filter(s => s.startLine == 2).length, 1); // function f
assertEq(allScripts.filter(s => s.startLine == 3).length, 1); // a = ...
assertEq(allScripts.filter(s => s.startLine == 4).length, 1); // b = ...
assertEq(allScripts.filter(s => s.startLine == 5).length, 1); // function g
assertEq(allScripts.filter(s => s.startLine == 9).length, 1); // d = ...
assertEq(allScripts.filter(s => s.startLine == 10).length, 1); // e = ...
assertEq(allScripts.filter(s => s.startLine == 11).length, 1); // f = ...