Skip to content

Commit 9386c85

Browse files
DivyaMohan94juanarbol
authored andcommitted
test: refactor to async/await
PR-URL: #44694 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 7cead59 commit 9386c85

File tree

1 file changed

+54
-69
lines changed

1 file changed

+54
-69
lines changed

‎test/sequential/test-debugger-exec.js‎

Lines changed: 54 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,61 @@ const startCLI = require('../common/debugger');
88

99
constassert=require('assert');
1010

11-
{
11+
constcli=startCLI([fixtures.path('debugger/alive.js')]);
1212

13-
constcli=startCLI([fixtures.path('debugger/alive.js')]);
13+
asyncfunctionwaitInitialBreak(){
14+
try{
15+
awaitcli.waitForInitialBreak();
16+
awaitcli.waitForPrompt();
17+
awaitcli.command('exec [typeof heartbeat, typeof process.exit]');
18+
assert.match(cli.output,/\['function','function'\]/,'works w/o paren');
1419

15-
functiononFatal(error){
16-
cli.quit();
17-
throwerror;
18-
}
20+
awaitcli.command('p [typeof heartbeat, typeof process.exit]');
21+
assert.match(
22+
cli.output,
23+
/\['function','function'\]/,
24+
'works w/o paren, short'
25+
);
26+
27+
awaitcli.command('repl');
28+
assert.match(
29+
cli.output,
30+
/PressCtrl\+Ctoleavedebugrepl\n+>/,
31+
'shows hint for how to leave repl'
32+
);
33+
assert.doesNotMatch(cli.output,/debug>/,'changes the repl style');
34+
35+
awaitcli.command('[typeof heartbeat, typeof process.exit]');
36+
awaitcli.waitFor(/function/);
37+
awaitcli.waitForPrompt();
38+
assert.match(
39+
cli.output,
40+
/\['function','function'\]/,
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-
/\['function','function'\]/,
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-
/\['function','function'\]/,
35-
'works w/o paren, short'
36-
);
37-
})
38-
.then(()=>cli.command('repl'))
39-
.then(()=>{
40-
assert.match(
41-
cli.output,
42-
/PressCtrl\+Ctoleavedebugrepl\n+>/,
43-
'shows hint for how to leave repl');
44-
assert.doesNotMatch(cli.output,/debug>/,'changes the repl style');
45-
})
46-
.then(()=>cli.command('[typeof heartbeat, typeof process.exit]'))
47-
.then(()=>cli.waitFor(/function/))
48-
.then(()=>cli.waitForPrompt())
49-
.then(()=>{
50-
assert.match(
51-
cli.output,
52-
/\['function','function'\]/,'can evaluate in the repl');
53-
assert.match(cli.output,/>$/);
54-
})
55-
.then(()=>cli.ctrlC())
56-
.then(()=>cli.waitFor(/debug>$/))
57-
.then(()=>cli.command('exec("[typeof heartbeat, typeof process.exit]")'))
58-
.then(()=>{
59-
assert.match(
60-
cli.output,
61-
/\['function','function'\]/,
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-
/\['function','function'\]/,
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-
/\['undefined','function'\]/,
79-
'non-paused exec can see global but not module-scope values');
80-
})
81-
.then(()=>cli.quit())
82-
.then(null,onFatal);
45+
awaitcli.ctrlC();
46+
awaitcli.waitFor(/debug>$/);
47+
awaitcli.command('exec("[typeof heartbeat, typeof process.exit]")');
48+
assert.match(cli.output,/\['function','function'\]/,'works w/ paren');
49+
awaitcli.command('p("[typeof heartbeat, typeof process.exit]")');
50+
assert.match(
51+
cli.output,
52+
/\['function','function'\]/,
53+
'works w/ paren, short'
54+
);
55+
56+
awaitcli.command('cont');
57+
awaitcli.command('exec [typeof heartbeat, typeof process.exit]');
58+
assert.match(
59+
cli.output,
60+
/\['undefined','function'\]/,
61+
'non-paused exec can see global but not module-scope values'
62+
);
63+
}finally{
64+
awaitcli.quit();
65+
}
8366
}
67+
68+
waitInitialBreak();

0 commit comments

Comments
(0)