| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -681,6 +681,9 @@ function createRepl(inspector) { | |||
| 681 | 681 | ||
| 682 | 682 | // List source code | |
| 683 | 683 | function list(delta = 5) { | |
| 684 | + if (!selectedFrame) { | ||
| 685 | + throw new ERR_DEBUGGER_ERROR('Requires execution to be paused'); | ||
| 686 | + } | ||
| 684 | 687 | return selectedFrame.list(delta).then(null, (error) => { | |
| 685 | 688 | print("You can't list source code right now"); | |
| 686 | 689 | throw error; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + | ||
| 4 | + common.skipIfInspectorDisabled(); | ||
| 5 | + | ||
| 6 | + const fixtures = require('../common/fixtures'); | ||
| 7 | + const startCLI = require('../common/debugger'); | ||
| 8 | + | ||
| 9 | + const assert = require('assert'); | ||
| 10 | + | ||
| 11 | + const cli = startCLI([fixtures.path('debugger/three-lines.js')]); | ||
| 12 | + | ||
| 13 | + (async () => { | ||
| 14 | + await cli.waitForInitialBreak(); | ||
| 15 | + await cli.waitForPrompt(); | ||
| 16 | + await cli.command('list(0)'); | ||
| 17 | + assert.match(cli.output, /> 1 let x = 1;/); | ||
| 18 | + await cli.command('list(1)'); | ||
| 19 | + assert.match(cli.output, /> 1 let x = 1;\r?\n {2}2 x = x \+ 1;/); | ||
| 20 | + await cli.command('list(10)'); | ||
| 21 | + assert.match(cli.output, /> 1 let x = 1;\r?\n {2}2 x = x \+ 1;\r?\n {2}3 module\.exports = x;\r?\n {2}4 /); | ||
| 22 | + await cli.command('c'); | ||
| 23 | + await cli.waitFor(/disconnect/); | ||
| 24 | + await cli.waitFor(/debug> $/); | ||
| 25 | + await cli.command('list()'); | ||
| 26 | + await cli.waitFor(/ERR_DEBUGGER_ERROR/); | ||
| 27 | + assert.match(cli.output, /Uncaught Error \[ERR_DEBUGGER_ERROR\]: Requires execution to be paused/); | ||
| 28 | + })() | ||
| 29 | + .finally(() => cli.quit()) | ||
| 30 | + .then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments