Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2e1b45d

Browse filesBrowse files
burgerboydaddygibfahn
authored andcommitted
test: add details in assertions in test-vm-context
PR-URL: #16116 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 4f47e2d commit 2e1b45d
Copy full SHA for 2e1b45d

File tree

Expand file treeCollapse file tree

1 file changed

+19
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-15
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-vm-context.js
+19-15Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ try {
5656
} catch (e) {
5757
gh1140Exception = e;
5858
assert.ok(/expected-filename/.test(e.stack),
59-
'expected appearance of filename in Error stack');
59+
`expected appearance of filename in Error stack: ${e.stack}`);
6060
}
61-
assert.ok(gh1140Exception,
62-
'expected exception from runInContext signature test');
61+
// This is outside of catch block to confirm catch block ran.
62+
assert.strictEqual(gh1140Exception.toString(), 'Error');
6363

6464
// GH-558, non-context argument segfaults / raises assertion
6565
const nonContextualSandboxErrorMsg =
@@ -90,18 +90,22 @@ Object.defineProperty(ctx, 'b', { configurable: false });
9090
ctx = vm.createContext(ctx);
9191
assert.strictEqual(script.runInContext(ctx), false);
9292

93-
// Error on the first line of a module should
94-
// have the correct line and column number
95-
assert.throws(() => {
96-
vm.runInContext(' throw new Error()', context, {
97-
filename: 'expected-filename.js',
98-
lineOffset: 32,
99-
columnOffset: 123
100-
});
101-
}, (err) => {
102-
return /^ \^/m.test(err.stack) &&
103-
/expected-filename\.js:33:131/.test(err.stack);
104-
}, 'Expected appearance of proper offset in Error stack');
93+
// Error on the first line of a module should have the correct line and column
94+
// number.
95+
{
96+
let stack = null;
97+
assert.throws(() => {
98+
vm.runInContext(' throw new Error()', context, {
99+
filename: 'expected-filename.js',
100+
lineOffset: 32,
101+
columnOffset: 123
102+
});
103+
}, (err) => {
104+
stack = err.stack;
105+
return /^ \^/m.test(stack) &&
106+
/expected-filename\.js:33:131/.test(stack);
107+
}, `stack not formatted as expected: ${stack}`);
108+
}
105109

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.