makepad/libs/stitch/tests/testsuite/forward.wast
2025-05-06 10:11:37 +02:00

20 lines
689 B
WebAssembly Text Format

(module
(func $even (export "even") (param $n i32) (result i32)
(if (result i32) (i32.eq (local.get $n) (i32.const 0))
(then (i32.const 1))
(else (call $odd (i32.sub (local.get $n) (i32.const 1))))
)
)
(func $odd (export "odd") (param $n i32) (result i32)
(if (result i32) (i32.eq (local.get $n) (i32.const 0))
(then (i32.const 0))
(else (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))