@@ -9,123 +9,102 @@ const startCLI = require('../common/debugger');
99const assert = require ( 'assert' ) ;
1010const path = require ( 'path' ) ;
1111
12- // Stepping through breakpoints.
13- {
14- const scriptFullPath = fixtures . path ( 'debugger' , 'break.js' ) ;
15- const script = path . relative ( process . cwd ( ) , scriptFullPath ) ;
16- const cli = startCLI ( [ script ] ) ;
17-
18- function onFatal ( error ) {
19- cli . quit ( ) ;
20- throw error ;
21- }
22-
23- cli . waitForInitialBreak ( )
24- . then ( ( ) => cli . waitForPrompt ( ) )
25- . then ( ( ) => {
26- assert . deepStrictEqual (
27- cli . breakInfo ,
28- { filename : script , line : 1 } ,
29- ) ;
30- assert . match (
31- cli . output ,
32- / > 1 (?: \( f u n c t i o n \( [ ^ ) ] + \) \{ ) ? c o n s t x = 1 0 ; / ,
33- 'shows the source and marks the current line' ) ;
34- } )
35- . then ( ( ) => cli . stepCommand ( 'n' ) )
36- . then ( ( ) => {
37- assert . ok (
38- cli . output . includes ( `break in ${ script } :2` ) ,
39- 'pauses in next line of the script' ) ;
40- assert . match (
41- cli . output ,
42- / > 2 l e t n a m e = ' W o r l d ' ; / ,
43- 'marks the 2nd line' ) ;
44- } )
45- . then ( ( ) => cli . stepCommand ( 'next' ) )
46- . then ( ( ) => {
47- assert . ok (
48- cli . output . includes ( `break in ${ script } :3` ) ,
49- 'pauses in next line of the script' ) ;
50- assert . match (
51- cli . output ,
52- / > 3 n a m e = ' R o b i n ' ; / ,
53- 'marks the 3nd line' ) ;
54- } )
55- . then ( ( ) => cli . stepCommand ( 'cont' ) )
56- . then ( ( ) => {
57- assert . ok (
58- cli . output . includes ( `break in ${ script } :10` ) ,
59- 'pauses on the next breakpoint' ) ;
60- assert . match (
61- cli . output ,
62- / > 1 0 d e b u g g e r ; / ,
63- 'marks the debugger line' ) ;
64- } )
65-
66- // Prepare additional breakpoints
67- . then ( ( ) => cli . command ( 'sb("break.js", 6)' ) )
68- . then ( ( ) => assert . doesNotMatch ( cli . output , / C o u l d n o t r e s o l v e b r e a k p o i n t / ) )
69- . then ( ( ) => cli . command ( 'sb("otherFunction()")' ) )
70- . then ( ( ) => cli . command ( 'sb(16)' ) )
71- . then ( ( ) => assert . doesNotMatch ( cli . output , / C o u l d n o t r e s o l v e b r e a k p o i n t / ) )
72- . then ( ( ) => cli . command ( 'breakpoints' ) )
73- . then ( ( ) => {
74- assert . ok ( cli . output . includes ( `#0 ${ script } :6` ) ) ;
75- assert . ok ( cli . output . includes ( `#1 ${ script } :16` ) ) ;
76- } )
77-
78- . then ( ( ) => cli . command ( 'list()' ) )
79- . then ( ( ) => {
80- assert . match (
81- cli . output ,
82- / > 1 0 d e b u g g e r ; / ,
83- 'prints and marks current line'
84- ) ;
85- assert . deepStrictEqual (
86- cli . parseSourceLines ( ) ,
87- [ 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ] ,
88- ) ;
89- } )
90- . then ( ( ) => cli . command ( 'list(2)' ) )
91- . then ( ( ) => {
92- assert . match (
93- cli . output ,
94- / > 1 0 d e b u g g e r ; / ,
95- 'prints and marks current line'
96- ) ;
97- assert . deepStrictEqual (
98- cli . parseSourceLines ( ) ,
99- [ 8 , 9 , 10 , 11 , 12 ] ,
100- ) ;
101- } )
102-
103- . then ( ( ) => cli . stepCommand ( 's' ) )
104- . then ( ( ) => cli . stepCommand ( '' ) )
105- . then ( ( ) => {
106- assert . match (
107- cli . output ,
108- / b r e a k i n n o d e : t i m e r s / ,
109- 'entered timers.js' ) ;
110- } )
111- . then ( ( ) => cli . stepCommand ( 'cont' ) )
112- . then ( ( ) => {
113- assert . ok (
114- cli . output . includes ( `break in ${ script } :16` ) ,
115- 'found breakpoint we set above w/ line number only' ) ;
116- } )
117- . then ( ( ) => cli . stepCommand ( 'cont' ) )
118- . then ( ( ) => {
119- assert . ok (
120- cli . output . includes ( `break in ${ script } :6` ) ,
121- 'found breakpoint we set above w/ line number & script' ) ;
122- } )
123- . then ( ( ) => cli . stepCommand ( '' ) )
124- . then ( ( ) => {
125- assert . ok (
126- cli . output . includes ( `debugCommand in ${ script } :14` ) ,
127- 'found function breakpoint we set above' ) ;
128- } )
129- . then ( ( ) => cli . quit ( ) )
130- . then ( null , onFatal ) ;
131- }
12+ const scriptFullPath = fixtures . path ( 'debugger' , 'break.js' ) ;
13+ const script = path . relative ( process . cwd ( ) , scriptFullPath ) ;
14+ const cli = startCLI ( [ script ] ) ;
15+
16+ ( async ( ) => {
17+ await cli . waitForInitialBreak ( ) ;
18+ await cli . waitForPrompt ( ) ;
19+ assert . deepStrictEqual (
20+ cli . breakInfo ,
21+ { filename : script , line : 1 } ,
22+ ) ;
23+ assert . match (
24+ cli . output ,
25+ / > 1 (?: \( f u n c t i o n \( [ ^ ) ] + \) \{ ) ? c o n s t x = 1 0 ; / ,
26+ 'shows the source and marks the current line' ) ;
27+
28+ await cli . stepCommand ( 'n' ) ;
29+ assert . ok (
30+ cli . output . includes ( `break in ${ script } :2` ) ,
31+ 'pauses in next line of the script' ) ;
32+ assert . match (
33+ cli . output ,
34+ / > 2 l e t n a m e = ' W o r l d ' ; / ,
35+ 'marks the 2nd line' ) ;
36+
37+ await cli . stepCommand ( 'next' ) ;
38+ assert . ok (
39+ cli . output . includes ( `break in ${ script } :3` ) ,
40+ 'pauses in next line of the script' ) ;
41+ assert . match (
42+ cli . output ,
43+ / > 3 n a m e = ' R o b i n ' ; / ,
44+ 'marks the 3nd line' ) ;
45+
46+ await cli . stepCommand ( 'cont' ) ;
47+ assert . ok (
48+ cli . output . includes ( `break in ${ script } :10` ) ,
49+ 'pauses on the next breakpoint' ) ;
50+ assert . match (
51+ cli . output ,
52+ / > 1 0 d e b u g g e r ; / ,
53+ 'marks the debugger line' ) ;
54+
55+ await cli . command ( 'sb("break.js", 6)' ) ;
56+ assert . doesNotMatch ( cli . output , / C o u l d n o t r e s o l v e b r e a k p o i n t / ) ;
57+
58+ await cli . command ( 'sb("otherFunction()")' ) ;
59+ await cli . command ( 'sb(16)' ) ;
60+ assert . doesNotMatch ( cli . output , / C o u l d n o t r e s o l v e b r e a k p o i n t / ) ;
61+
62+ await cli . command ( 'breakpoints' ) ;
63+ assert . ok ( cli . output . includes ( `#0 ${ script } :6` ) ) ;
64+ assert . ok ( cli . output . includes ( `#1 ${ script } :16` ) ) ;
65+
66+ await cli . command ( 'list()' ) ;
67+ assert . match (
68+ cli . output ,
69+ / > 1 0 d e b u g g e r ; / ,
70+ 'prints and marks current line'
71+ ) ;
72+ assert . deepStrictEqual (
73+ cli . parseSourceLines ( ) ,
74+ [ 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ] ,
75+ ) ;
76+
77+ await cli . command ( 'list(2)' ) ;
78+ assert . match (
79+ cli . output ,
80+ / > 1 0 d e b u g g e r ; / ,
81+ 'prints and marks current line'
82+ ) ;
83+ assert . deepStrictEqual (
84+ cli . parseSourceLines ( ) ,
85+ [ 8 , 9 , 10 , 11 , 12 ] ,
86+ ) ;
87+
88+ await cli . stepCommand ( 's' ) ;
89+ await cli . stepCommand ( '' ) ;
90+ assert . match (
91+ cli . output ,
92+ / b r e a k i n n o d e : t i m e r s / ,
93+ 'entered timers.js' ) ;
94+
95+ await cli . stepCommand ( 'cont' ) ;
96+ assert . ok (
97+ cli . output . includes ( `break in ${ script } :16` ) ,
98+ 'found breakpoint we set above w/ line number only' ) ;
99+
100+ await cli . stepCommand ( 'cont' ) ;
101+ assert . ok (
102+ cli . output . includes ( `break in ${ script } :6` ) ,
103+ 'found breakpoint we set above w/ line number & script' ) ;
104+
105+ await cli . stepCommand ( '' ) ;
106+ assert . ok (
107+ cli . output . includes ( `debugCommand in ${ script } :14` ) ,
108+ 'found function breakpoint we set above' ) ;
109+ } ) ( ) . finally ( ( ) => cli . quit ( ) )
110+ . then ( common . mustCall ( ) ) ;
0 commit comments