Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions test/parallel/test-vm-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ assert.throws(() => {

// Issue GH-1140:
// Test runInContext signature
let gh1140Exception;
let gh1140Exp;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the value in changing the variable name (no idea what Exp is supposed to mean).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 ... generally we use more expressive variable names as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper fix is implemented in pull request #16116

try {
vm.runInContext('throw new Error()', context, 'expected-filename.js');
} catch (e) {
gh1140Exception = e;
gh1140Exp = e;
assert.ok(/expected-filename/.test(e.stack),
'expected appearance of filename in Error stack');
`expected appearance of filename in Error stack: ${e.stack}`);
}
assert.ok(gh1140Exception,
'expected exception from runInContext signature test');
assert.ok(gh1140Exp,
`expected exception from runInContext signature test: ${gh1140Exp}`);

// GH-558, non-context argument segfaults / raises assertion
const nonContextualSandboxErrorMsg =
Expand Down Expand Up @@ -92,15 +92,17 @@ assert.strictEqual(script.runInContext(ctx), false);

// Error on the first line of a module should
// have the correct line and column number
let assertErrStack = null;
assert.throws(() => {
vm.runInContext('throw new Error()', context, {
filename: 'expected-filename.js',
lineOffset: 32,
columnOffset: 123
});
}, (err) => {
assertErrStack = err.stack;
return /expected-filename\.js:33:130/.test(err.stack);
}, 'Expected appearance of proper offset in Error stack');
}, `expected appearance of proper offset in Error stack: ${assertErrStack}`);

// https://github.com/nodejs/node/issues/6158
ctx = new Proxy({}, {});
Expand Down