Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f8b2d7a

Browse filesBrowse files
DivyaMohan94danielleadams
authored andcommitted
test: refactor to async/await
PR-URL: #44694 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 910fbd0 commit f8b2d7a
Copy full SHA for f8b2d7a

File tree

Expand file treeCollapse file tree

1 file changed

+54
-69
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+54
-69
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/sequential/test-debugger-exec.js
+54-69Lines changed: 54 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,61 @@ const startCLI = require('../common/debugger');
88

99
const 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, /\[ 'function', 'function' \]/, '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+
/\[ 'function', 'function' \]/,
24+
'works w/o paren, short'
25+
);
26+
27+
await cli.command('repl');
28+
assert.match(
29+
cli.output,
30+
/Press Ctrl\+C to leave debug repl\n+> /,
31+
'shows hint for how to leave repl'
32+
);
33+
assert.doesNotMatch(cli.output, /debug>/, 'changes the repl style');
34+
35+
await cli.command('[typeof heartbeat, typeof process.exit]');
36+
await cli.waitFor(/function/);
37+
await cli.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-
/Press Ctrl\+C to leave debug repl\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+
await cli.ctrlC();
46+
await cli.waitFor(/debug> $/);
47+
await cli.command('exec("[typeof heartbeat, typeof process.exit]")');
48+
assert.match(cli.output, /\[ 'function', 'function' \]/, 'works w/ paren');
49+
await cli.command('p("[typeof heartbeat, typeof process.exit]")');
50+
assert.match(
51+
cli.output,
52+
/\[ 'function', 'function' \]/,
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+
/\[ 'undefined', 'function' \]/,
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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.