Add tests.

This commit is contained in:
losfair 2019-03-09 02:58:10 +08:00
parent 25034ece07
commit c6dfbcd90d
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,12 @@
(module
(type $binop (func (param i32 i32) (result i32)))
(table 1 100 anyfunc)
(elem (i32.const 10) $add)
(func $main (export "main") (result i32)
(call_indirect (type $binop) (i32.const 42) (i32.const 1) (i32.const 9))
)
(func $add (param i32) (param i32) (result i32)
(i32.add (get_local 0) (get_local 1))
)
)

View File

@ -0,0 +1,26 @@
(module
(global $g1 (mut i32) (i32.const 0))
(global $g2 (mut i32) (i32.const 99))
(func $main (export "main")
(if (i32.eq (get_global $g1) (i32.const 0))
(then)
(else unreachable)
)
(if (i32.eq (get_global $g2) (i32.const 99))
(then)
(else unreachable)
)
(set_global $g1 (i32.add (get_global $g1) (i32.const 1)))
(set_global $g2 (i32.sub (get_global $g2) (i32.const 1)))
(if (i32.eq (get_global $g1) (i32.const 1))
(then)
(else unreachable)
)
(if (i32.eq (get_global $g2) (i32.const 98))
(then)
(else unreachable)
)
)
)