Skip to content

Commit cb0b4a6

Browse files
committed
test: add test for debugging one line files
This commit adds a regression test for debugging of single line files. Refs: #4297 PR-URL: #4298 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]>
1 parent 2a60e2a commit cb0b4a6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = function foo(arg) { return arg; }

test/parallel/test-vm-debug-context.js

+18
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ assert.strictEqual(vm.runInDebugContext(undefined), undefined);
5353
assert.equal(breaks, 1);
5454
})();
5555

56+
// Can set listeners and breakpoints on a single line file
57+
(function() {
58+
const Debug = vm.runInDebugContext('Debug');
59+
const fn = require(common.fixturesDir + '/exports-function-with-param');
60+
let called = false;
61+
62+
Debug.setListener(function(event, state, data) {
63+
if (data.constructor.name === 'BreakEvent') {
64+
called = true;
65+
}
66+
});
67+
68+
Debug.setBreakPoint(fn);
69+
fn('foo');
70+
assert.strictEqual(Debug.showBreakPoints(fn), '(arg) { [B0]return arg; }');
71+
assert.strictEqual(called, true);
72+
})();
73+
5674
// See https://github.com/nodejs/node/issues/1190, fatal errors should not
5775
// crash the process.
5876
var script = common.fixturesDir + '/vm-run-in-debug-context.js';

0 commit comments

Comments
 (0)