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

33 lines
829 B
JavaScript

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());
});
});
});