修复构建脚本和WASM测试问题
This commit is contained in:
@@ -76,9 +76,16 @@ async function loadModule(modulePath) {
|
||||
throw new Error(`Unsupported WASM loader type: ${typeof required}`);
|
||||
}
|
||||
|
||||
function allocString(module, value) {
|
||||
const size = module.lengthBytesUTF8(value) + 1;
|
||||
const ptr = module._malloc(size);
|
||||
module.stringToUTF8(value, ptr, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
function callJsonFunction(module, exportName, payload) {
|
||||
const requestText = typeof payload === "string" ? payload : JSON.stringify(payload);
|
||||
const requestPtr = module.allocateUTF8(requestText);
|
||||
const requestPtr = allocString(module, requestText);
|
||||
let responsePtr = 0;
|
||||
|
||||
try {
|
||||
@@ -343,7 +350,7 @@ const suite = [
|
||||
assertions: [
|
||||
{ path: "success", equals: true },
|
||||
{ path: "res_data.success", equals: true },
|
||||
{ path: "res_data.OPERATION.frames", lengthEquals: 2 },
|
||||
{ path: "res_data.OPERATION.OPERATION.frames", lengthEquals: 2 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -435,7 +442,8 @@ async function main() {
|
||||
|
||||
ensure(typeof module._init_func === "function", "_init_func is not exported");
|
||||
ensure(typeof module._func === "function", "_func is not exported");
|
||||
ensure(typeof module.allocateUTF8 === "function", "allocateUTF8 is not exported");
|
||||
ensure(typeof module.lengthBytesUTF8 === "function", "lengthBytesUTF8 is not exported");
|
||||
ensure(typeof module.stringToUTF8 === "function", "stringToUTF8 is not exported");
|
||||
ensure(typeof module.UTF8ToString === "function", "UTF8ToString is not exported");
|
||||
|
||||
const initResponse = callNoArgJsonFunction(module, "_init_func");
|
||||
|
||||
Reference in New Issue
Block a user