blob: 5b0baa56bc2305d02663b6760a61de370417edce [file] [edit]
import { instantiate } from "../wabt-wrapper.js"
import * as assert from "../assert.js"
/*
(module
(type $0 (func))
(type $1 (func (param i32) (param i32) (result i32)))
(tag $e1)
(tag $e2 (param i32))
(export "simple_throw_catch" (func 0))
(func $0
(type 1)
(block $b1
(block $b2 (result i32)
(try_table (result i32)
(catch $e1 $b1)
(catch $e2 $b2)
(local.get 0)
(i32.eqz)
(if (then (throw $e1)) (else))
(local.get 1)
(i32.eqz)
(if (then (throw $e2 (i32.const 2))) (else))
(i32.const 1)
(return)
)
)
(return)
)
(i32.const 3)
(return)
)
)
*/
var wasm_module = new WebAssembly.Module(new Uint8Array([
0x00,0x61,0x73,0x6d,0x01,0x00,0x00,0x00,0x01,0x8e,0x80,0x80,0x80,0x00,0x03,0x60,0x00,0x00,0x60,0x02,0x7f,0x7f,0x01,0x7f,0x60,0x01,0x7f,0x00,0x03,0x82,0x80,0x80,0x80,0x00,0x01,0x01,0x0d,0x85,0x80,0x80,0x80,0x00,0x02,0x00,0x00,0x00,0x02,0x07,0x96,0x80,0x80,0x80,0x00,0x01,0x12,0x73,0x69,0x6d,0x70,0x6c,0x65,0x5f,0x74,0x68,0x72,0x6f,0x77,0x5f,0x63,0x61,0x74,0x63,0x68,0x00,0x00,0x0a,0xb1,0x80,0x80,0x80,0x00,0x01,0xab,0x80,0x80,0x80,0x00,0x00,0x02,0x40,0x02,0x7f,0x1f,0x7f,0x02,0x00,0x00,0x01,0x00,0x01,0x00,0x20,0x00,0x45,0x04,0x40,0x08,0x00,0x0b,0x20,0x01,0x45,0x04,0x40,0x41,0x02,0x08,0x01,0x0b,0x41,0x01,0x0f,0x0b,0x0b,0x0f,0x0b,0x41,0x03,0x0f,0x0b,
]));
var instance = new WebAssembly.Instance(wasm_module);
const { simple_throw_catch } = instance.exports
for (let i = 0; i < wasmTestLoopCount; ++i) {
assert.eq(simple_throw_catch(1, 1), 1)
assert.eq(simple_throw_catch(1, 0), 2)
assert.eq(simple_throw_catch(0, 1), 3)
}