24 lines
773 B
JavaScript
Raw Normal View History

load( "spiderMonkey.wasm.js" );
var wasm = read( "spiderMonkey.wasm", "binary" ); // https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Shell_global_objects
var testData = JSON.parse( read( "testdata.json" ) );
2017-04-04 20:51:10 +02:00
2017-04-08 20:16:39 +02:00
function callExport(instance) {
var result = {};
for (var method in testData) {
try{
result[method] = instance.exports[method]( ...testData[method] ).toString();
}catch(err){
result[method] = err.toString();
}
2017-04-08 20:16:39 +02:00
}
// save the test result
const original = redirect( "testresult.json" );
putstr( JSON.stringify(result) );
redirect( original );
2017-04-08 20:16:39 +02:00
}
2017-04-04 20:51:10 +02:00
WebAssembly.instantiate( wasm, wasmImports ).then(
obj => callExport(obj.instance),
2017-04-04 20:51:10 +02:00
reason => console.log(reason)
);