| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -319,6 +319,7 @@ function runInThisContext(code, options) { | |||
| 319 | 319 | ||
| 320 | 320 | function compileFunction(code, params, options = kEmptyObject) { | |
| 321 | 321 | validateString(code, 'code'); | |
| 322 | + validateObject(options, 'options'); | ||
| 322 | 323 | if (params !== undefined) { | |
| 323 | 324 | validateStringArray(params, 'params'); | |
| 324 | 325 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -172,7 +172,30 @@ const vm = require('vm'); | |||
| 172 | 172 | 'Received null' | |
| 173 | 173 | }); | |
| 174 | 174 | ||
| 175 | - // vm.compileFunction('', undefined, null); | ||
| 175 | + // Test for invalid options type | ||
| 176 | + assert.throws(() => { | ||
| 177 | + vm.compileFunction('', [], null); | ||
| 178 | + }, { | ||
| 179 | + name: 'TypeError', | ||
| 180 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 181 | + message: 'The "options" argument must be of type object. Received null' | ||
| 182 | + }); | ||
| 183 | + | ||
| 184 | + assert.throws(() => { | ||
| 185 | + vm.compileFunction('', [], 'string'); | ||
| 186 | + }, { | ||
| 187 | + name: 'TypeError', | ||
| 188 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 189 | + message: 'The "options" argument must be of type object. Received type string (\'string\')' | ||
| 190 | + }); | ||
| 191 | + | ||
| 192 | + assert.throws(() => { | ||
| 193 | + vm.compileFunction('', [], 123); | ||
| 194 | + }, { | ||
| 195 | + name: 'TypeError', | ||
| 196 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 197 | + message: 'The "options" argument must be of type object. Received type number (123)' | ||
| 198 | + }); | ||
| 176 | 199 | ||
| 177 | 200 | const optionTypes = { | |
| 178 | 201 | 'filename': 'string', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments