Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactored context type err message to regex #12596

Closed
wants to merge 3 commits into from
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
17 changes: 13 additions & 4 deletions test/parallel/test-vm-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ assert.strictEqual('lala', context.thing);
// Issue GH-227:
assert.throws(function() {
vm.runInNewContext('', null, 'some.js');
}, TypeError);
}, /^TypeError: sandbox must be an object$/);

// Issue GH-1140:
console.error('test runInContext signature');
Expand All @@ -62,9 +62,18 @@ assert.ok(gh1140Exception,
'expected exception from runInContext signature test');

// GH-558, non-context argument segfaults / raises assertion
[undefined, null, 0, 0.0, '', {}, []].forEach(function(e) {
assert.throws(function() { script.runInContext(e); }, TypeError);
assert.throws(function() { vm.runInContext('', e); }, TypeError);
const nonContextualSandboxErrorMsg =
/^TypeError: contextifiedSandbox argument must be an object\.$/;
const contextifiedSandboxErrorMsg =
/^TypeError: sandbox argument must have been converted to a context\.$/;
[
[undefined, nonContextualSandboxErrorMsg],
[null, nonContextualSandboxErrorMsg], [0, nonContextualSandboxErrorMsg],
[0.0, nonContextualSandboxErrorMsg], ['', nonContextualSandboxErrorMsg],
[{}, contextifiedSandboxErrorMsg], [[], contextifiedSandboxErrorMsg]
].forEach((e) => {
assert.throws(() => { script.runInContext(e[0]); }, e[1]);
assert.throws(() => { vm.runInContext('', e[0]); }, e[1]);
});

// Issue GH-693:
Expand Down