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

Browse filesBrowse files
Muhsin Abdul-MusawwirMylesBorins
authored andcommitted
test: refactored context type err message to regex
PR-URL: #12596 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 32f905a commit 8044b83
Copy full SHA for 8044b83

File tree

Expand file treeCollapse file tree

1 file changed

+13
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-4
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
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ assert.strictEqual('lala', context.thing);
2525
// Issue GH-227:
2626
assert.throws(function() {
2727
vm.runInNewContext('', null, 'some.js');
28-
}, TypeError);
28+
}, /^TypeError: sandbox must be an object$/);
2929

3030
// Issue GH-1140:
3131
console.error('test runInContext signature');
@@ -41,9 +41,18 @@ assert.ok(gh1140Exception,
4141
'expected exception from runInContext signature test');
4242

4343
// GH-558, non-context argument segfaults / raises assertion
44-
[undefined, null, 0, 0.0, '', {}, []].forEach(function(e) {
45-
assert.throws(function() { script.runInContext(e); }, TypeError);
46-
assert.throws(function() { vm.runInContext('', e); }, TypeError);
44+
const nonContextualSandboxErrorMsg =
45+
/^TypeError: contextifiedSandbox argument must be an object\.$/;
46+
const contextifiedSandboxErrorMsg =
47+
/^TypeError: sandbox argument must have been converted to a context\.$/;
48+
[
49+
[undefined, nonContextualSandboxErrorMsg],
50+
[null, nonContextualSandboxErrorMsg], [0, nonContextualSandboxErrorMsg],
51+
[0.0, nonContextualSandboxErrorMsg], ['', nonContextualSandboxErrorMsg],
52+
[{}, contextifiedSandboxErrorMsg], [[], contextifiedSandboxErrorMsg]
53+
].forEach((e) => {
54+
assert.throws(() => { script.runInContext(e[0]); }, e[1]);
55+
assert.throws(() => { vm.runInContext('', e[0]); }, e[1]);
4756
});
4857

4958
// Issue GH-693:

0 commit comments

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