Skip to content

Commit

Permalink
test: convert then to async/await
Browse files Browse the repository at this point in the history
PR-URL: #43292
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
meekdenzo authored and danielleadams committed Jun 13, 2022
1 parent 201f3d7 commit 18fffe6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
25 changes: 13 additions & 12 deletions test/parallel/test-debugger-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,22 @@ function launchTarget(...args) {
assert.ifError(error);
}

return launchTarget('--inspect=0', script)
.then(({ childProc, host, port }) => {
(async () => {
try {
const { childProc, host, port } = await launchTarget('--inspect=0', script);
target = childProc;
cli = startCLI([`${host || '127.0.0.1'}:${port}`]);
return cli.waitForPrompt();
})
.then(() => cli.command('sb("alive.js", 3)'))
.then(() => cli.waitFor(/break/))
.then(() => cli.waitForPrompt())
.then(() => {
await cli.waitForPrompt();
await cli.command('sb("alive.js", 3)');
await cli.waitFor(/break/);
await cli.waitForPrompt();
assert.match(
cli.output,
/> 3 {3}\+\+x;/,
'marks the 3rd line');
})
.then(() => cleanup())
.then(null, cleanup);
'marks the 3rd line'
);
} finally {
cleanup();
}
})().then(common.mustCall());
}
47 changes: 22 additions & 25 deletions test/parallel/test-debugger-extract-function-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@ const assert = require('assert');

const cli = startCLI([fixtures.path('debugger', 'three-lines.js')]);

function onFatal(error) {
cli.quit();
throw error;
}

cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('exec a = function func() {}; a;'))
.then(() => assert.match(cli.output, /\[Function: func\]/))
.then(() => cli.command('exec a = function func () {}; a;'))
.then(() => assert.match(cli.output, /\[Function\]/))
.then(() => cli.command('exec a = function() {}; a;'))
.then(() => assert.match(cli.output, /\[Function: function\]/))
.then(() => cli.command('exec a = () => {}; a;'))
.then(() => assert.match(cli.output, /\[Function\]/))
.then(() => cli.command('exec a = function* func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction: func\]/))
.then(() => cli.command('exec a = function *func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction: \*func\]/))
.then(() => cli.command('exec a = function*func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction: function\*func\]/))
.then(() => cli.command('exec a = function * func() {}; a;'))
.then(() => assert.match(cli.output, /\[GeneratorFunction\]/))
.then(() => cli.quit())
.then(null, onFatal);
(async () => {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
await cli.command('exec a = function func() {}; a;');
assert.match(cli.output, /\[Function: func\]/);
await cli.command('exec a = function func () {}; a;');
assert.match(cli.output, /\[Function\]/);
await cli.command('exec a = function() {}; a;');
assert.match(cli.output, /\[Function: function\]/);
await cli.command('exec a = () => {}; a;');
assert.match(cli.output, /\[Function\]/);
await cli.command('exec a = function* func() {}; a;');
assert.match(cli.output, /\[GeneratorFunction: func\]/);
await cli.command('exec a = function *func() {}; a;');
assert.match(cli.output, /\[GeneratorFunction: \*func\]/);
await cli.command('exec a = function*func() {}; a;');
assert.match(cli.output, /\[GeneratorFunction: function\*func\]/);
await cli.command('exec a = function * func() {}; a;');
assert.match(cli.output, /\[GeneratorFunction\]/);
})()
.finally(() => cli.quit())
.then(common.mustCall());

0 comments on commit 18fffe6

Please sign in to comment.