Skip to content

Commit 1819974

Browse files
committed
update promise to async/await
1 parent 5d92ddc commit 1819974

File tree

1 file changed

+32
-44
lines changed

1 file changed

+32
-44
lines changed

test/sequential/test-debugger-preserve-breaks.js

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,42 @@ const startCLI = require('../common/debugger');
99
const assert = require('assert');
1010
const path = require('path');
1111

12+
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
13+
const script = path.relative(process.cwd(), scriptFullPath);
14+
1215
// Run after quit.
13-
{
14-
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
15-
const script = path.relative(process.cwd(), scriptFullPath);
16+
const runTest = async () => {
1617
const cli = startCLI([script]);
18+
try {
19+
await cli.waitForInitialBreak();
20+
await cli.waitForPrompt();
21+
await cli.command('breakpoints');
22+
assert.match(cli.output, /No breakpoints yet/);
23+
await cli.command('sb(2)');
24+
await cli.command('sb(3)');
25+
await cli.command('breakpoints');
26+
assert.ok(cli.output.includes(`#0 ${script}:2`));
27+
assert.ok(cli.output.includes(`#1 ${script}:3`));
28+
await cli.stepCommand('c'); // hit line 2
29+
await cli.stepCommand('c'); // hit line 3
30+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
31+
await cli.command('restart');
32+
await cli.waitForInitialBreak();
33+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
34+
await cli.stepCommand('c');
35+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
36+
await cli.stepCommand('c');
37+
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
38+
await cli.command('breakpoints');
39+
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
40+
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
41+
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);
1742

18-
function onFatal(error) {
43+
await cli.quit();
44+
} catch (error) {
1945
cli.quit();
2046
throw error;
2147
}
48+
};
2249

23-
return cli.waitForInitialBreak()
24-
.then(() => cli.waitForPrompt())
25-
.then(() => cli.command('breakpoints'))
26-
.then(() => {
27-
assert.match(cli.output, /No breakpoints yet/);
28-
})
29-
.then(() => cli.command('sb(2)'))
30-
.then(() => cli.command('sb(3)'))
31-
.then(() => cli.command('breakpoints'))
32-
.then(() => {
33-
assert.ok(cli.output.includes(`#0 ${script}:2`));
34-
assert.ok(cli.output.includes(`#1 ${script}:3`));
35-
})
36-
.then(() => cli.stepCommand('c')) // hit line 2
37-
.then(() => cli.stepCommand('c')) // hit line 3
38-
.then(() => {
39-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
40-
})
41-
.then(() => cli.command('restart'))
42-
.then(() => cli.waitForInitialBreak())
43-
.then(() => {
44-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
45-
})
46-
.then(() => cli.stepCommand('c'))
47-
.then(() => {
48-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
49-
})
50-
.then(() => cli.stepCommand('c'))
51-
.then(() => {
52-
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
53-
})
54-
.then(() => cli.command('breakpoints'))
55-
.then(() => {
56-
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
57-
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
58-
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);
59-
})
60-
.then(() => cli.quit())
61-
.then(null, onFatal);
62-
}
50+
runTest();

0 commit comments

Comments
 (0)