Skip to content

Commit

Permalink
update promise to async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
poorvitusam committed Sep 16, 2022
1 parent 5d92ddc commit 1819974
Showing 1 changed file with 32 additions and 44 deletions.
76 changes: 32 additions & 44 deletions test/sequential/test-debugger-preserve-breaks.js
Expand Up @@ -9,54 +9,42 @@ const startCLI = require('../common/debugger');
const assert = require('assert');
const path = require('path');

const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
const script = path.relative(process.cwd(), scriptFullPath);

// Run after quit.
{
const scriptFullPath = fixtures.path('debugger', 'three-lines.js');
const script = path.relative(process.cwd(), scriptFullPath);
const runTest = async () => {
const cli = startCLI([script]);
try {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
await cli.command('breakpoints');
assert.match(cli.output, /No breakpoints yet/);
await cli.command('sb(2)');
await cli.command('sb(3)');
await cli.command('breakpoints');
assert.ok(cli.output.includes(`#0 ${script}:2`));
assert.ok(cli.output.includes(`#1 ${script}:3`));
await cli.stepCommand('c'); // hit line 2
await cli.stepCommand('c'); // hit line 3
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
await cli.command('restart');
await cli.waitForInitialBreak();
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
await cli.stepCommand('c');
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
await cli.stepCommand('c');
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
await cli.command('breakpoints');
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);

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

return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('breakpoints'))
.then(() => {
assert.match(cli.output, /No breakpoints yet/);
})
.then(() => cli.command('sb(2)'))
.then(() => cli.command('sb(3)'))
.then(() => cli.command('breakpoints'))
.then(() => {
assert.ok(cli.output.includes(`#0 ${script}:2`));
assert.ok(cli.output.includes(`#1 ${script}:3`));
})
.then(() => cli.stepCommand('c')) // hit line 2
.then(() => cli.stepCommand('c')) // hit line 3
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
})
.then(() => cli.command('restart'))
.then(() => cli.waitForInitialBreak())
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
})
.then(() => cli.stepCommand('c'))
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 2 });
})
.then(() => cli.stepCommand('c'))
.then(() => {
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 3 });
})
.then(() => cli.command('breakpoints'))
.then(() => {
const msg = `SCRIPT: ${script}, OUTPUT: ${cli.output}`;
assert.ok(cli.output.includes(`#0 ${script}:2`), msg);
assert.ok(cli.output.includes(`#1 ${script}:3`), msg);
})
.then(() => cli.quit())
.then(null, onFatal);
}
runTest();

0 comments on commit 1819974

Please sign in to comment.