forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (28 loc) · 1.08 KB
/
index.js
File metadata and controls
31 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// the message is inconsistency between some nodejs versions
const UNKNOWN_FUNCTION_TABLE = /invalid index into function table|invalid function/;
it("should support tables", function() {
return import("./wasm-table.wat").then(function(wasm) {
expect(wasm.callByIndex(0)).toEqual(42);
expect(wasm.callByIndex(1)).toEqual(13);
expect(() => wasm.callByIndex(2)).toThrow(UNKNOWN_FUNCTION_TABLE);
});
});
it("should support exported tables", function() {
return import("./wasm-table-export.wat").then(function(wasm) {
expect(wasm.table).toBeInstanceOf(WebAssembly.Table);
expect(wasm.table.length).toBe(2);
const e0 = wasm.table.get(0);
const e1 = wasm.table.get(1);
expect(e0).toBeInstanceOf(Function);
expect(e1).toBeInstanceOf(Function);
expect(e0()).toEqual(42);
expect(e1()).toEqual(13);
});
});
it("should support imported tables", function() {
return import("./wasm-table-imported.wat").then(function(wasm) {
expect(wasm.callByIndex(0)).toEqual(42);
expect(wasm.callByIndex(1)).toEqual(13);
expect(() => wasm.callByIndex(2)).toThrow(UNKNOWN_FUNCTION_TABLE);
});
});