1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/@webassemblyjs/helper-module-context/test/index.js

33 lines
829 B
JavaScript
Raw Normal View History

2023-12-18 13:12:25 +08:00
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());
});
});
});