2019-09-12 21:54:35 +02:00
|
|
|
load( "{test}.wasm.js" );
|
|
|
|
var wasm = wasmTextToBinary( read( "{test}.wat" ) );
|
2019-06-17 19:00:16 +02:00
|
|
|
var testData = JSON.parse( read( "testdata.json" ) );
|
2018-12-01 18:32:18 +01:00
|
|
|
|
|
|
|
function callExport(instance) {
|
2019-06-17 19:00:16 +02:00
|
|
|
var result = {};
|
|
|
|
for (var method in testData) {
|
|
|
|
try{
|
|
|
|
result[method] = instance.exports[method]( ...testData[method] ).toString();
|
|
|
|
}catch(err){
|
|
|
|
result[method] = err.toString();
|
|
|
|
}
|
2018-12-01 18:32:18 +01:00
|
|
|
}
|
2019-06-17 19:00:16 +02:00
|
|
|
// save the test result
|
|
|
|
const original = redirect( "testresult.json" );
|
|
|
|
putstr( JSON.stringify(result) );
|
|
|
|
redirect( original );
|
2018-12-01 18:32:18 +01:00
|
|
|
}
|
|
|
|
|
2019-07-03 20:09:22 +02:00
|
|
|
WebAssembly.instantiate( wasm, wasmImports ).then(
|
2019-06-17 19:00:16 +02:00
|
|
|
obj => callExport(obj.instance),
|
2018-12-01 18:32:18 +01:00
|
|
|
reason => console.log(reason)
|
|
|
|
);
|