Skip to content

Commit eeb5cc6

Browse files
dYaleBridgeAR
authored andcommitted
test: add typeerror for vm/compileFunction params
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>
1 parent 5ca0cf7 commit eeb5cc6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/parallel/test-vm-basic.js

+14
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,20 @@ const vm = require('vm');
209209
}
210210
);
211211

212+
// Testing for non Array type-based failures
213+
[Boolean(), Number(), null, Object(), Symbol(), {}].forEach(
214+
(value) => {
215+
common.expectsError(() => {
216+
vm.compileFunction('', value);
217+
}, {
218+
type: TypeError,
219+
code: 'ERR_INVALID_ARG_TYPE',
220+
message: 'The "params" argument must be of type Array. ' +
221+
`Received type ${typeof value}`
222+
});
223+
}
224+
);
225+
212226
assert.strictEqual(
213227
vm.compileFunction(
214228
'return a;',

0 commit comments

Comments
 (0)