blob: 06005d60f580b2d1e4677469fc10c9439a8b93c1 (
plain)
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
32
|
const { assert } = require("chai");
const { parse } = require("@webassemblyjs/wast-parser");
const { moduleContextFromModuleAST } = require("../lib");
const contextFromWast = wast => moduleContextFromModuleAST(parse(wast).body[0]);
describe("module context", () => {
describe("start segment", () => {
it("should return the start function offset", () => {
const context = contextFromWast(`
(module
(func)
(func)
(start 1)
)
`);
assert.isOk(context.getStart());
assert.typeOf(context.getStart(), "number");
assert.equal(context.getStart(), 1);
});
it("should return null if no start function", () => {
const context = contextFromWast(`
(module (func))
`);
assert.isNull(context.getStart());
});
});
});
|