Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 15, 2020
1 parent 27796db commit 250e37c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/TestCases.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const describeCases = config => {
if (module.substr(0, 2) === "./") {
const p = path.join(outputDirectory, module);
const fn = vm.runInThisContext(
"(function(require, module, exports, __dirname, it, expect) {" +
"(function(require, module, exports, __dirname, __filename, it, expect) {" +
"global.expect = expect;" +
'function nsObj(m) { Object.defineProperty(m, Symbol.toStringTag, { value: "Module" }); return m; }' +
fs.readFileSync(p, "utf-8") +
Expand All @@ -306,6 +306,7 @@ const describeCases = config => {
m,
m.exports,
outputDirectory,
p,
_it,
expect
);
Expand Down
12 changes: 12 additions & 0 deletions test/cases/side-effects/issue-11673/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Worker } from "worker_threads";
import { X } from "./module";
// test

it("should compile", done => {
expect(X()).toBe("X");
const worker = new Worker(new URL("worker.js", import.meta.url));
worker.once("message", value => {
expect(value).toBe(42);
done();
});
});
9 changes: 9 additions & 0 deletions test/cases/side-effects/issue-11673/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import value from "package";

export function X() {
return "X";
}

export function Y() {
return value;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/cases/side-effects/issue-11673/test.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var supportsWorker = require("../../../helpers/supportsWorker");

module.exports = function (config) {
return supportsWorker();
};
4 changes: 4 additions & 0 deletions test/cases/side-effects/issue-11673/worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Y } from "./module";
import { parentPort } from "worker_threads";

parentPort.postMessage(Y());

0 comments on commit 250e37c

Please sign in to comment.