blob: 6cf94dc9e14246fdee3ab4ee2e96dd3aa5cf64bf [file] [log] [blame] [edit]
(module
(func $even (export "even") (param $n i32) (result i32)
(if i32 (i32.eq (local.get $n) (i32.const 0))
(i32.const 1)
(call $odd (i32.sub (local.get $n) (i32.const 1)))
)
)
(func $odd (export "odd") (param $n i32) (result i32)
(if i32 (i32.eq (local.get $n) (i32.const 0))
(i32.const 0)
(call $even (i32.sub (local.get $n) (i32.const 1)))
)
)
)
(assert_return (invoke "even" (i32.const 13)) (i32.const 0))
(assert_return (invoke "even" (i32.const 20)) (i32.const 1))
(assert_return (invoke "odd" (i32.const 13)) (i32.const 1))
(assert_return (invoke "odd" (i32.const 20)) (i32.const 0))