Skip to content

Commit

Permalink
test: add typeerror for vm/compileFunction params
Browse files Browse the repository at this point in the history
  • Loading branch information
dYale committed Nov 6, 2018
1 parent 7b1297d commit a401f13
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/parallel/test-vm-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,20 @@ const vm = require('vm');
}
);

// Testing for non Array type-based failures
[Boolean(), Number(), null, Object(), Symbol(), {}].forEach(
(value) => {
common.expectsError(() => {
vm.compileFunction('', value);
}, {
type: TypeError,
code: 'ERR_INVALID_ARG_TYPE',
message: 'The "params" argument must be of type Array. '
+ `Received type ${typeof value}`
});
}
);

assert.strictEqual(
vm.compileFunction(
'return a;',
Expand Down

0 comments on commit a401f13

Please sign in to comment.