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:
parent
4e6d28a710
commit
3212f77ac6
@ -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;',
|
||||
|
Loading…
x
Reference in New Issue
Block a user