2017-09-01 17:03:41 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const assert = require('assert');
|
2018-06-01 15:13:43 +02:00
|
|
|
const { Worker } = require('worker_threads');
|
2017-09-01 17:03:41 +02:00
|
|
|
|
|
|
|
// Do not use isMainThread so that this test itself can be run inside a Worker.
|
|
|
|
if (!process.env.HAS_STARTED_WORKER) {
|
|
|
|
process.env.HAS_STARTED_WORKER = 1;
|
|
|
|
const w = new Worker(fixtures.path('syntax', 'bad_syntax.js'));
|
|
|
|
w.on('message', common.mustNotCall());
|
|
|
|
w.on('error', common.mustCall((err) => {
|
2019-02-05 21:47:08 +01:00
|
|
|
assert.strictEqual(err.constructor, SyntaxError);
|
2020-03-27 00:54:52 +08:00
|
|
|
assert.strictEqual(err.name, 'SyntaxError');
|
2017-09-01 17:03:41 +02:00
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
throw new Error('foo');
|
|
|
|
}
|