Debian Codegraph @

js/src/jit-test/tests/debug/Frame-onStep-19.js

raw
1 // Stepping should ignore nested function declarations.
2
3 // Nested functions are hoisted to the top of the function body,
4 // so technically the first thing that happens when you call the outer function
5 // is that each inner function is created and bound to a local variable.
6 // But users don't actually want to see that happen when they're stepping.
7 // It's super confusing.
8
9 load(libdir + "stepping.js");
10
11 testStepping(
12 `\
13 (function() { // line 1
14 let x = 1; // line 2
15 funcb("funcb"); // line 3
16 function funcb(msg) { // line 4
17 console.log(msg)
18 }
19 }) // line 7
20 `,
21 [1, 2, 3, 7]);
22
23 // Stopping at the ClassDeclaration on line 8 is fine. For that matter,
24 // stopping on line 5 wouldn't be so bad if we did it after line 3 and before
25 // line 8; alas, the actual order of execution is 5, 2, 3, 8... which is too
26 // confusing.
27 testStepping(
28 `\
29 function f() { // 1
30 var x = 0; // 2
31 a(); // 3
32
33 function a() { // 5
34 x += 1; // 6
35 } // 7
36 class Car {} // 8
37 return x; // 9
38 } // 10
39 f
40 `,
41 [1, 2, 3, 8, 9, 10]);