11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci{ 81cb0ef41Sopenharmony_ci const expectedErr = { 91cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 101cb0ef41Sopenharmony_ci name: 'TypeError' 111cb0ef41Sopenharmony_ci }; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci assert.throws(() => { 141cb0ef41Sopenharmony_ci new Worker(__filename, { execArgv: 'hello' }); 151cb0ef41Sopenharmony_ci }, expectedErr); 161cb0ef41Sopenharmony_ci assert.throws(() => { 171cb0ef41Sopenharmony_ci new Worker(__filename, { execArgv: 6 }); 181cb0ef41Sopenharmony_ci }, expectedErr); 191cb0ef41Sopenharmony_ci} 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci{ 221cb0ef41Sopenharmony_ci const expectedErr = { 231cb0ef41Sopenharmony_ci code: 'ERR_WORKER_INVALID_EXEC_ARGV', 241cb0ef41Sopenharmony_ci name: 'Error' 251cb0ef41Sopenharmony_ci }; 261cb0ef41Sopenharmony_ci assert.throws(() => { 271cb0ef41Sopenharmony_ci new Worker(__filename, { execArgv: ['--foo'] }); 281cb0ef41Sopenharmony_ci }, expectedErr); 291cb0ef41Sopenharmony_ci assert.throws(() => { 301cb0ef41Sopenharmony_ci new Worker(__filename, { execArgv: ['--title=blah'] }); 311cb0ef41Sopenharmony_ci }, expectedErr); 321cb0ef41Sopenharmony_ci assert.throws(() => { 331cb0ef41Sopenharmony_ci new Worker(__filename, { execArgv: ['--redirect-warnings'] }); 341cb0ef41Sopenharmony_ci }, expectedErr); 351cb0ef41Sopenharmony_ci} 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci{ 381cb0ef41Sopenharmony_ci const expectedErr = { 391cb0ef41Sopenharmony_ci code: 'ERR_WORKER_INVALID_EXEC_ARGV', 401cb0ef41Sopenharmony_ci name: 'Error' 411cb0ef41Sopenharmony_ci }; 421cb0ef41Sopenharmony_ci assert.throws(() => { 431cb0ef41Sopenharmony_ci new Worker(__filename, { 441cb0ef41Sopenharmony_ci env: { 451cb0ef41Sopenharmony_ci NODE_OPTIONS: '--nonexistent-options' 461cb0ef41Sopenharmony_ci } 471cb0ef41Sopenharmony_ci }); 481cb0ef41Sopenharmony_ci }, expectedErr); 491cb0ef41Sopenharmony_ci} 50