Skip to content

Commit 7abe26e

Browse files
authored
Merge pull request webpack#6529 from webpack/test/wasm-order
add wasm order test case
2 parents f34fe53 + e5b9340 commit 7abe26e

File tree

8 files changed

+44
-0
lines changed

8 files changed

+44
-0
lines changed

test/cases/wasm/order/a.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { trackA, results } from "./tracker";
2+
import "./b.js";
3+
import "./wasm.wasm";
4+
5+
trackA();
6+
7+
export default results;

test/cases/wasm/order/b.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { trackB } from "./tracker";
2+
3+
trackB();

test/cases/wasm/order/c.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { trackC } from "./tracker";
2+
3+
trackC();
4+
5+
export const magicNumber = 42;

test/cases/wasm/order/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
it("should be evaluated in the correct order", () => {
2+
return import("./a").then(({ default: results }) => {
3+
return Promise.resolve().then(() => { // wait an extra tick to get the tick from the tracker
4+
results.should.be.eql(["b", "c", "wasm42", "a", "tick"]);
5+
});
6+
});
7+
});

test/cases/wasm/order/test.filter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var supportsWebAssembly = require("../../../helpers/supportsWebAssembly");
2+
3+
module.exports = function(config) {
4+
return supportsWebAssembly();
5+
};

test/cases/wasm/order/tracker.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export let results = [];
2+
3+
export function trackA() { results.push("a"); }
4+
export function trackB() { results.push("b"); }
5+
export function trackC() { results.push("c"); }
6+
export function trackWasm(number) { results.push("wasm" + number); }
7+
8+
Promise.resolve().then(() => results.push("tick"));

test/cases/wasm/order/wasm.wasm

82 Bytes
Binary file not shown.

test/cases/wasm/order/wasm.wat

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(module
2+
(func $trackWasm (import "./tracker" "trackWasm") (param i32))
3+
(global $magicNumber (import "./c.js" "magicNumber") i32)
4+
(func $start
5+
get_global $magicNumber
6+
call $trackWasm
7+
)
8+
(start $start)
9+
)

0 commit comments

Comments
 (0)