@@ -8,76 +8,61 @@ const startCLI = require('../common/debugger');
88
99const assert = require ( 'assert' ) ;
1010
11- {
11+ const cli = startCLI ( [ fixtures . path ( 'debugger/alive.js' ) ] ) ;
1212
13- const cli = startCLI ( [ fixtures . path ( 'debugger/alive.js' ) ] ) ;
13+ async function waitInitialBreak ( ) {
14+ try {
15+ await cli . waitForInitialBreak ( ) ;
16+ await cli . waitForPrompt ( ) ;
17+ await cli . command ( 'exec [typeof heartbeat, typeof process.exit]' ) ;
18+ assert . match ( cli . output , / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / , 'works w/o paren' ) ;
1419
15- function onFatal ( error ) {
16- cli . quit ( ) ;
17- throw error ;
18- }
20+ await cli . command ( 'p [typeof heartbeat, typeof process.exit]' ) ;
21+ assert . match (
22+ cli . output ,
23+ / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / ,
24+ 'works w/o paren, short'
25+ ) ;
26+
27+ await cli . command ( 'repl' ) ;
28+ assert . match (
29+ cli . output ,
30+ / P r e s s C t r l \+ C t o l e a v e d e b u g r e p l \n + > / ,
31+ 'shows hint for how to leave repl'
32+ ) ;
33+ assert . doesNotMatch ( cli . output , / d e b u g > / , 'changes the repl style' ) ;
34+
35+ await cli . command ( '[typeof heartbeat, typeof process.exit]' ) ;
36+ await cli . waitFor ( / f u n c t i o n / ) ;
37+ await cli . waitForPrompt ( ) ;
38+ assert . match (
39+ cli . output ,
40+ / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / ,
41+ 'can evaluate in the repl'
42+ ) ;
43+ assert . match ( cli . output , / > $ / ) ;
1944
20- cli . waitForInitialBreak ( )
21- . then ( ( ) => cli . waitForPrompt ( ) )
22- . then ( ( ) => cli . command ( 'exec [typeof heartbeat, typeof process.exit]' ) )
23- . then ( ( ) => {
24- assert . match (
25- cli . output ,
26- / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / ,
27- 'works w/o paren'
28- ) ;
29- } )
30- . then ( ( ) => cli . command ( 'p [typeof heartbeat, typeof process.exit]' ) )
31- . then ( ( ) => {
32- assert . match (
33- cli . output ,
34- / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / ,
35- 'works w/o paren, short'
36- ) ;
37- } )
38- . then ( ( ) => cli . command ( 'repl' ) )
39- . then ( ( ) => {
40- assert . match (
41- cli . output ,
42- / P r e s s C t r l \+ C t o l e a v e d e b u g r e p l \n + > / ,
43- 'shows hint for how to leave repl' ) ;
44- assert . doesNotMatch ( cli . output , / d e b u g > / , 'changes the repl style' ) ;
45- } )
46- . then ( ( ) => cli . command ( '[typeof heartbeat, typeof process.exit]' ) )
47- . then ( ( ) => cli . waitFor ( / f u n c t i o n / ) )
48- . then ( ( ) => cli . waitForPrompt ( ) )
49- . then ( ( ) => {
50- assert . match (
51- cli . output ,
52- / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / , 'can evaluate in the repl' ) ;
53- assert . match ( cli . output , / > $ / ) ;
54- } )
55- . then ( ( ) => cli . ctrlC ( ) )
56- . then ( ( ) => cli . waitFor ( / d e b u g > $ / ) )
57- . then ( ( ) => cli . command ( 'exec("[typeof heartbeat, typeof process.exit]")' ) )
58- . then ( ( ) => {
59- assert . match (
60- cli . output ,
61- / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / ,
62- 'works w/ paren'
63- ) ;
64- } )
65- . then ( ( ) => cli . command ( 'p("[typeof heartbeat, typeof process.exit]")' ) )
66- . then ( ( ) => {
67- assert . match (
68- cli . output ,
69- / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / ,
70- 'works w/ paren, short'
71- ) ;
72- } )
73- . then ( ( ) => cli . command ( 'cont' ) )
74- . then ( ( ) => cli . command ( 'exec [typeof heartbeat, typeof process.exit]' ) )
75- . then ( ( ) => {
76- assert . match (
77- cli . output ,
78- / \[ ' u n d e f i n e d ' , ' f u n c t i o n ' \] / ,
79- 'non-paused exec can see global but not module-scope values' ) ;
80- } )
81- . then ( ( ) => cli . quit ( ) )
82- . then ( null , onFatal ) ;
45+ await cli . ctrlC ( ) ;
46+ await cli . waitFor ( / d e b u g > $ / ) ;
47+ await cli . command ( 'exec("[typeof heartbeat, typeof process.exit]")' ) ;
48+ assert . match ( cli . output , / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / , 'works w/ paren' ) ;
49+ await cli . command ( 'p("[typeof heartbeat, typeof process.exit]")' ) ;
50+ assert . match (
51+ cli . output ,
52+ / \[ ' f u n c t i o n ' , ' f u n c t i o n ' \] / ,
53+ 'works w/ paren, short'
54+ ) ;
55+
56+ await cli . command ( 'cont' ) ;
57+ await cli . command ( 'exec [typeof heartbeat, typeof process.exit]' ) ;
58+ assert . match (
59+ cli . output ,
60+ / \[ ' u n d e f i n e d ' , ' f u n c t i o n ' \] / ,
61+ 'non-paused exec can see global but not module-scope values'
62+ ) ;
63+ } finally {
64+ await cli . quit ( ) ;
65+ }
8366}
67+
68+ waitInitialBreak ( ) ;
0 commit comments