diff options
Diffstat (limited to 'test/spec/fac.wast')
-rw-r--r-- | test/spec/fac.wast | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/test/spec/fac.wast b/test/spec/fac.wast index a9e437be2..ef10991a8 100644 --- a/test/spec/fac.wast +++ b/test/spec/fac.wast @@ -1,19 +1,23 @@ (module ;; Recursive factorial (func (export "fac-rec") (param i64) (result i64) - (if i64 (i64.eq (local.get 0) (i64.const 0)) - (i64.const 1) - (i64.mul (local.get 0) (call 0 (i64.sub (local.get 0) (i64.const 1)))) + (if (result i64) (i64.eq (local.get 0) (i64.const 0)) + (then (i64.const 1)) + (else + (i64.mul (local.get 0) (call 0 (i64.sub (local.get 0) (i64.const 1)))) + ) ) ) ;; Recursive factorial named (func $fac-rec-named (export "fac-rec-named") (param $n i64) (result i64) - (if i64 (i64.eq (local.get $n) (i64.const 0)) - (i64.const 1) - (i64.mul - (local.get $n) - (call $fac-rec-named (i64.sub (local.get $n) (i64.const 1))) + (if (result i64) (i64.eq (local.get $n) (i64.const 0)) + (then (i64.const 1)) + (else + (i64.mul + (local.get $n) + (call $fac-rec-named (i64.sub (local.get $n) (i64.const 1))) + ) ) ) ) @@ -27,8 +31,8 @@ (loop (if (i64.eq (local.get 1) (i64.const 0)) - (br 2) - (block + (then (br 2)) + (else (local.set 2 (i64.mul (local.get 1) (local.get 2))) (local.set 1 (i64.sub (local.get 1) (i64.const 1))) ) @@ -49,8 +53,8 @@ (loop $loop (if (i64.eq (local.get $i) (i64.const 0)) - (br $done) - (block + (then (br $done)) + (else (local.set $res (i64.mul (local.get $i) (local.get $res))) (local.set $i (i64.sub (local.get $i) (i64.const 1))) ) @@ -82,4 +86,4 @@ (assert_return (invoke "fac-rec-named" (i64.const 25)) (i64.const 7034535277573963776)) (assert_return (invoke "fac-iter-named" (i64.const 25)) (i64.const 7034535277573963776)) (assert_return (invoke "fac-opt" (i64.const 25)) (i64.const 7034535277573963776)) -(assert_trap (invoke "fac-rec" (i64.const 1073741824)) "call stack exhausted") +(assert_exhaustion (invoke "fac-rec" (i64.const 1073741824)) "call stack exhausted") |