summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/spec/forward.wast
blob: 43ab4934854f6d9fd79c743fe44811ab0260c35d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(module
  (func $even (export "even") (param $n i32) (result i32)
    (if i32 (i32.eq (get_local $n) (i32.const 0))
      (i32.const 1)
      (call $odd (i32.sub (get_local $n) (i32.const 1)))
    )
  )

  (func $odd (export "odd") (param $n i32) (result i32)
    (if i32 (i32.eq (get_local $n) (i32.const 0))
      (i32.const 0)
      (call $even (i32.sub (get_local $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))