test: add typeerror for vm/compileFunction params

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Dan Corman 2018-11-06 16:19:52 +00:00 committed by Rich Trott
parent 4e6d28a710
commit 3212f77ac6

View File

@ -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;',