| 1 | require('../targets/wasm_exec.js'); |
| 2 | |
| 3 | function runTests() { |
| 4 | let testCall = (name, params, expected) => { |
| 5 | let result = go._inst.exports[name].apply(null, params); |
| 6 | if (result !== expected) { |
| 7 | console.error(`${name}(...${params}): expected result ${expected}, got ${result}`); |
| 8 | } |
| 9 | } |
| 10 | |
| 11 | // These are the same tests as in TestWasmExport. |
| 12 | testCall('hello', [], undefined); |
| 13 | testCall('add', [3, 5], 8); |
| 14 | testCall('add', [7, 9], 16); |
| 15 | testCall('add', [6, 1], 7); |
| 16 | testCall('reentrantCall', [2, 3], 5); |
| 17 | testCall('reentrantCall', [1, 8], 9); |
| 18 | } |
| 19 | |
| 20 | let go = new Go(); |
| 21 | go.importObject.tester = { |