Skip to content

Commit 585db59

Browse files
dYalecodebytere
authored andcommitted
test: add typeerror for vm/compileFunction params
PR-URL: #24179 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5c2c5b9 commit 585db59

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
@@ -207,6 +207,20 @@ const vm = require('vm');
207207
}
208208
);
209209

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

0 commit comments

Comments
 (0)