mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 19:43:44 +00:00
wasm: add test for js.FuncOf
While there are some browser tests, Node.js is just a lot better for testing this kind of stuff because it's much faster and we don't need a browser for this.
This commit is contained in:
committed by
Ron Evans
parent
5e3c816373
commit
cd2bb8333d
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
require('../targets/wasm_exec.js');
|
||||
|
||||
var callback;
|
||||
|
||||
global.setCallback = (cb) => {
|
||||
callback = cb;
|
||||
};
|
||||
|
||||
global.callCallback = () => {
|
||||
console.log('calling callback!');
|
||||
let result = callback(1, 2, 3, 4);
|
||||
console.log('result from callback:', result);
|
||||
};
|
||||
|
||||
let go = new Go();
|
||||
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
|
||||
go.run(result.instance);
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user