Skip to content

Commit a5f311b

Browse files
committed
test: Check the context line seen through n steps after calling setContextLineNumber
1 parent 42f4c14 commit a5f311b

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
let x = 0;
2+
x = 1;
3+
x = 2;
4+
x = 3;
5+
x = 4;
6+
x = 5;
7+
x = 6;
8+
x = 7;
9+
x = 8;
10+
x = 9;
11+
x = 10;
12+
x = 11;
13+
x = 12;
14+
x = 13;
15+
x = 14;
16+
x = 15;
17+
x = 16;
18+
x = 17;
19+
x = 18;
20+
module.exports = x;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { skipIfInspectorDisabled } from '../common/index.mjs';
2+
skipIfInspectorDisabled();
3+
4+
import { path } from '../common/fixtures.mjs';
5+
import startCLI from '../common/debugger.js';
6+
7+
import assert from 'assert';
8+
9+
const script = path('debugger', 'twenty-lines.js');
10+
const cli = startCLI([script]);
11+
12+
function onFatal(error) {
13+
cli.quit();
14+
throw error;
15+
}
16+
17+
function getLastline(output) {
18+
const splitedByLine = output.split('\n');
19+
return splitedByLine[splitedByLine.length - 2];
20+
}
21+
22+
// Stepping through breakpoints.
23+
try {
24+
await cli.waitForInitialBreak();
25+
await cli.waitForPrompt();
26+
27+
// Make sure the initial value is 2.
28+
await cli.stepCommand('n');
29+
assert.ok(getLastline(cli.output).includes('4 x = 3;'));
30+
31+
await cli.command('setContextLineNumber(5)');
32+
await cli.stepCommand('n');
33+
assert.ok(getLastline(cli.output).includes('8 x = 7;'));
34+
35+
await cli.command('setContextLineNumber(3)');
36+
await cli.stepCommand('n');
37+
assert.ok(getLastline(cli.output).includes('7 x = 6;'));
38+
39+
await cli.command('list(3)');
40+
await cli.stepCommand('n');
41+
assert.ok(getLastline(cli.output).includes('7 x = 6;'));
42+
43+
await cli.quit();
44+
} catch (error) {
45+
onFatal(error);
46+
}

0 commit comments

Comments
 (0)