Skip to content

Commit

Permalink
test: add typeerror for vm/compileFunction params
Browse files Browse the repository at this point in the history
PR-URL: #24179
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
dYale authored and codebytere committed Jan 12, 2019
1 parent 5c2c5b9 commit 585db59
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 @@ -207,6 +207,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 585db59

Please sign in to comment.