| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d3cada5 commit 9a139b3
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,25 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { Worker } = require('worker_threads'); | ||
| 5 | + | ||
| 6 | + const cases = [ | ||
| 7 | + { code: 'throw "boom";', value: 'boom' }, | ||
| 8 | + { code: 'throw 42;', value: 42 }, | ||
| 9 | + { code: 'throw 7n;', value: 7n }, | ||
| 10 | + { code: 'throw true;', value: true }, | ||
| 11 | + { code: 'throw null;', value: null }, | ||
| 12 | + { code: 'throw undefined;', value: undefined }, | ||
| 13 | + { code: 'throw Symbol.for("a");', value: Symbol.for('a') }, | ||
| 14 | + ]; | ||
| 15 | + | ||
| 16 | + for (const { code, value } of cases) { | ||
| 17 | + const worker = new Worker(code, { eval: true }); | ||
| 18 | + worker.on('message', common.mustNotCall()); | ||
| 19 | + worker.on('error', common.mustCall((err) => { | ||
| 20 | + assert.strictEqual(err, value); | ||
| 21 | + })); | ||
| 22 | + worker.on('exit', common.mustCall((exitCode) => { | ||
| 23 | + assert.strictEqual(exitCode, 1); | ||
| 24 | + })); | ||
| 25 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments