@@ -46,7 +46,7 @@ assert.strictEqual('lala', context.thing);
46
46
// Issue GH-227:
47
47
assert.throws(function() {
48
48
vm.runInNewContext('', null, 'some.js');
49
- }, TypeError);
49
+ }, /^ TypeError: sandbox must be an object$/ );
50
50
51
51
// Issue GH-1140:
52
52
console.error('test runInContext signature');
@@ -62,9 +62,18 @@ assert.ok(gh1140Exception,
62
62
'expected exception from runInContext signature test');
63
63
64
64
// GH-558, non-context argument segfaults / raises assertion
65
- [undefined, null, 0, 0.0, '', {}, []].forEach(function(e) {
66
- assert.throws(function() { script.runInContext(e); }, TypeError);
67
- assert.throws(function() { vm.runInContext('', e); }, TypeError);
65
+ const nonContextualSandboxErrorMsg =
66
+ /^TypeError: contextifiedSandbox argument must be an object\.$/;
67
+ const contextifiedSandboxErrorMsg =
68
+ /^TypeError: sandbox argument must have been converted to a context\.$/;
69
+ [
70
+ [undefined, nonContextualSandboxErrorMsg],
71
+ [null, nonContextualSandboxErrorMsg], [0, nonContextualSandboxErrorMsg],
72
+ [0.0, nonContextualSandboxErrorMsg], ['', nonContextualSandboxErrorMsg],
73
+ [{}, contextifiedSandboxErrorMsg], [[], contextifiedSandboxErrorMsg]
74
+ ].forEach((e) => {
75
+ assert.throws(() => { script.runInContext(e[0]); }, e[1]);
76
+ assert.throws(() => { vm.runInContext('', e[0]); }, e[1]);
68
77
});
69
78
70
79
// Issue GH-693:
0 commit comments