mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
101 lines
2.8 KiB
JavaScript
101 lines
2.8 KiB
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());
|
|
});
|
|
|
|
it("should retrive the type of implemented functions", () => {
|
|
const context = contextFromWast(`
|
|
(module
|
|
(func (param i32) (result i64))
|
|
(func (param i64) (result i32))
|
|
(func (result i64))
|
|
(func)
|
|
)
|
|
`);
|
|
|
|
assert.deepEqual(context.getFunction(0), {
|
|
args: ["i32"],
|
|
result: ["i64"]
|
|
});
|
|
assert.deepEqual(context.getFunction(1), {
|
|
args: ["i64"],
|
|
result: ["i32"]
|
|
});
|
|
assert.deepEqual(context.getFunction(2), { args: [], result: ["i64"] });
|
|
assert.deepEqual(context.getFunction(3), { args: [], result: [] });
|
|
});
|
|
|
|
it("should retrive the type of imported functions", () => {
|
|
const context = contextFromWast(`
|
|
(module
|
|
(import "a" "a" (func (param i32) (result i32)))
|
|
(import "a" "b" (func (result i64)))
|
|
(import "a" "c" (func))
|
|
(func (result f32))
|
|
)
|
|
`);
|
|
|
|
assert.deepEqual(context.getFunction(0), {
|
|
args: ["i32"],
|
|
result: ["i32"]
|
|
});
|
|
assert.deepEqual(context.getFunction(1), {
|
|
args: [],
|
|
result: ["i64"]
|
|
});
|
|
assert.deepEqual(context.getFunction(2), { args: [], result: [] });
|
|
assert.deepEqual(context.getFunction(3), { args: [], result: ["f32"] });
|
|
});
|
|
|
|
it("should retrive the type of functions with type ref", () => {
|
|
const context = contextFromWast(`
|
|
(module
|
|
(type (func (param i32) (result i32)))
|
|
(type (func (result i64)))
|
|
(type (func))
|
|
|
|
(import "a" "a" (func (type 0)))
|
|
(import "a" "b" (func (type 1)))
|
|
(func (type 2))
|
|
)
|
|
`);
|
|
|
|
assert.deepEqual(context.getFunction(0), {
|
|
args: ["i32"],
|
|
result: ["i32"]
|
|
});
|
|
assert.deepEqual(context.getFunction(1), {
|
|
args: [],
|
|
result: ["i64"]
|
|
});
|
|
assert.deepEqual(context.getFunction(2), { args: [], result: [] });
|
|
});
|
|
});
|
|
});
|