11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Do not use isMainThread so that this test itself can be run inside a Worker. 81cb0ef41Sopenharmony_ciif (!process.env.HAS_STARTED_WORKER) { 91cb0ef41Sopenharmony_ci process.env.HAS_STARTED_WORKER = 1; 101cb0ef41Sopenharmony_ci const w = new Worker(fixtures.path('syntax', 'bad_syntax.js')); 111cb0ef41Sopenharmony_ci w.on('message', common.mustNotCall()); 121cb0ef41Sopenharmony_ci w.on('error', common.mustCall((err) => { 131cb0ef41Sopenharmony_ci assert.strictEqual(err.constructor, SyntaxError); 141cb0ef41Sopenharmony_ci assert.strictEqual(err.name, 'SyntaxError'); 151cb0ef41Sopenharmony_ci })); 161cb0ef41Sopenharmony_ci} else { 171cb0ef41Sopenharmony_ci throw new Error('foo'); 181cb0ef41Sopenharmony_ci} 19