Skip to content

Commit 4cd0cf5

Browse files
authored
Merge pull request webpack#7379 from xtuc/refactor-use-wast-in-tests
switch to tests to wast
2 parents c513cac + 00eafa6 commit 4cd0cf5

32 files changed

+115
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"url-loader": "^0.6.2",
7373
"val-loader": "^1.0.2",
7474
"vm-browserify": "~0.0.0",
75+
"wast-loader": "^1.5.5",
7576
"webpack-dev-middleware": "^1.9.0",
7677
"worker-loader": "^1.1.1",
7778
"xxhashjs": "^0.2.1"

test/TestCases.template.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ const describeCases = config => {
143143
{
144144
test: /\.pug/,
145145
loader: "pug-loader"
146+
},
147+
{
148+
test: /\.wat$/i,
149+
loader: "wast-loader",
150+
type: "webassembly/experimental"
146151
}
147152
]
148153
},

test/cases/wasm/import-wasm-wasm/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
it("should allow to run a WebAssembly module with imports", function() {
2-
return import("./wasm.wasm").then(function(wasm) {
2+
return import("./wasm.wat").then(function(wasm) {
33
const result = wasm.addNumber(20);
44
expect(result).toEqual(42);
55
});
-78 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(module
2+
(type $t0 (func (result i32)))
3+
(type $t1 (func (param i32) (result i32)))
4+
(import "./wasm2.wat" "getNumber" (func $./wasm2.wasm.getNumber (type $t0)))
5+
(func $addNumber (export "addNumber") (type $t1) (param $p0 i32) (result i32)
6+
(i32.add
7+
(get_local $p0)
8+
(call $./wasm2.wasm.getNumber))))
9+
-42 Bytes
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(module
2+
(type $t0 (func (result i32)))
3+
(func $getNumber (export "getNumber") (type $t0) (result i32)
4+
(i32.const 22)))
5+

test/cases/wasm/imports-circular/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addNumber } from "./wasm.wasm";
1+
import { addNumber } from "./wasm.wat";
22

33
export var result = addNumber(22);
44

-74 Bytes
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(module
2+
(type $t0 (func (result i32)))
3+
(type $t1 (func (param i32) (result i32)))
4+
(import "./module" "getNumber" (func $./module.getNumber (type $t0)))
5+
(func $addNumber (export "addNumber") (type $t1) (param $p0 i32) (result i32)
6+
(i32.add
7+
(get_local $p0)
8+
(call $./module.getNumber))))
9+

0 commit comments

Comments
 (0)