From eeb5cc63052c762b3058594d1ba29f739d35986f Mon Sep 17 00:00:00 2001 From: Dan Corman Date: Tue, 6 Nov 2018 16:19:52 +0000 Subject: [PATCH] test: add typeerror for vm/compileFunction params PR-URL: https://github.com/nodejs/node/pull/24179 Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- test/parallel/test-vm-basic.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/parallel/test-vm-basic.js b/test/parallel/test-vm-basic.js index df0c7df1062c14..29e2a8b5251934 100644 --- a/test/parallel/test-vm-basic.js +++ b/test/parallel/test-vm-basic.js @@ -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;',