summaryrefslogtreecommitdiff
path: root/test/spec/forward.wast
diff options
context:
space:
mode:
Diffstat (limited to 'test/spec/forward.wast')
-rw-r--r--test/spec/forward.wast20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/spec/forward.wast b/test/spec/forward.wast
new file mode 100644
index 000000000..43ab49348
--- /dev/null
+++ b/test/spec/forward.wast
@@ -0,0 +1,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))