|
| 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