summaryrefslogtreecommitdiff
path: root/test/spec
diff options
context:
space:
mode:
Diffstat (limited to 'test/spec')
-rw-r--r--test/spec/exception-handling-old.wast8
-rw-r--r--test/spec/old_br_if.wast4
-rw-r--r--test/spec/old_call.wast48
-rw-r--r--test/spec/old_call_indirect.wast62
-rw-r--r--test/spec/old_float_exprs.wast32
-rw-r--r--test/spec/old_unreachable.wast6
-rw-r--r--test/spec/stack.wast32
7 files changed, 118 insertions, 74 deletions
diff --git a/test/spec/exception-handling-old.wast b/test/spec/exception-handling-old.wast
index 48fbe8389..75bfe70e8 100644
--- a/test/spec/exception-handling-old.wast
+++ b/test/spec/exception-handling-old.wast
@@ -605,8 +605,12 @@
(throw $e-i32
(if (result i32)
(i32.const 0)
- (pop i32) ;; pop is within an if true body
- (i32.const 3)
+ (then
+ (pop i32) ;; pop is within an if true body
+ )
+ (else
+ (i32.const 3)
+ )
)
)
)
diff --git a/test/spec/old_br_if.wast b/test/spec/old_br_if.wast
index 44aeffbe7..9ed24f153 100644
--- a/test/spec/old_br_if.wast
+++ b/test/spec/old_br_if.wast
@@ -37,10 +37,10 @@
)
(func (export "as-if-then") (param i32 i32)
- (block (if (local.get 0) (br_if 1 (local.get 1)) (call $dummy)))
+ (block (if (local.get 0) (then (br_if 1 (local.get 1)) )(else (call $dummy))))
)
(func (export "as-if-else") (param i32 i32)
- (block (if (local.get 0) (call $dummy) (br_if 1 (local.get 1))))
+ (block (if (local.get 0) (then (call $dummy) )(else (br_if 1 (local.get 1)))))
)
(func (export "nested-block-value") (param i32) (result i32)
diff --git a/test/spec/old_call.wast b/test/spec/old_call.wast
index 00bd97397..ed2cd286b 100644
--- a/test/spec/old_call.wast
+++ b/test/spec/old_call.wast
@@ -46,41 +46,61 @@
(func $fac (export "fac") (param i64) (result i64)
(if i64 (i64.eqz (local.get 0))
- (i64.const 1)
- (i64.mul (local.get 0) (call $fac (i64.sub (local.get 0) (i64.const 1))))
+ (then
+ (i64.const 1)
+ )
+ (else
+ (i64.mul (local.get 0) (call $fac (i64.sub (local.get 0) (i64.const 1))))
+ )
)
)
(func $fac-acc (export "fac-acc") (param i64 i64) (result i64)
(if i64 (i64.eqz (local.get 0))
- (local.get 1)
- (call $fac-acc
- (i64.sub (local.get 0) (i64.const 1))
- (i64.mul (local.get 0) (local.get 1))
+ (then
+ (local.get 1)
+ )
+ (else
+ (call $fac-acc
+ (i64.sub (local.get 0) (i64.const 1))
+ (i64.mul (local.get 0) (local.get 1))
+ )
)
)
)
(func $fib (export "fib") (param i64) (result i64)
(if i64 (i64.le_u (local.get 0) (i64.const 1))
- (i64.const 1)
- (i64.add
- (call $fib (i64.sub (local.get 0) (i64.const 2)))
- (call $fib (i64.sub (local.get 0) (i64.const 1)))
+ (then
+ (i64.const 1)
+ )
+ (else
+ (i64.add
+ (call $fib (i64.sub (local.get 0) (i64.const 2)))
+ (call $fib (i64.sub (local.get 0) (i64.const 1)))
+ )
)
)
)
(func $even (export "even") (param i64) (result i32)
(if i32 (i64.eqz (local.get 0))
- (i32.const 44)
- (call $odd (i64.sub (local.get 0) (i64.const 1)))
+ (then
+ (i32.const 44)
+ )
+ (else
+ (call $odd (i64.sub (local.get 0) (i64.const 1)))
+ )
)
)
(func $odd (export "odd") (param i64) (result i32)
(if i32 (i64.eqz (local.get 0))
- (i32.const 99)
- (call $even (i64.sub (local.get 0) (i64.const 1)))
+ (then
+ (i32.const 99)
+ )
+ (else
+ (call $even (i64.sub (local.get 0) (i64.const 1)))
+ )
)
)
diff --git a/test/spec/old_call_indirect.wast b/test/spec/old_call_indirect.wast
index 41f4316f6..00ecd0863 100644
--- a/test/spec/old_call_indirect.wast
+++ b/test/spec/old_call_indirect.wast
@@ -103,12 +103,16 @@
(func $fac (export "fac") (type $over-i64)
(if i64 (i64.eqz (local.get 0))
- (i64.const 1)
- (i64.mul
- (local.get 0)
- (call_indirect (type $over-i64)
- (i64.sub (local.get 0) (i64.const 1))
- (i32.const 12)
+ (then
+ (i64.const 1)
+ )
+ (else
+ (i64.mul
+ (local.get 0)
+ (call_indirect (type $over-i64)
+ (i64.sub (local.get 0) (i64.const 1))
+ (i32.const 12)
+ )
)
)
)
@@ -116,15 +120,19 @@
(func $fib (export "fib") (type $over-i64)
(if i64 (i64.le_u (local.get 0) (i64.const 1))
- (i64.const 1)
- (i64.add
- (call_indirect (type $over-i64)
- (i64.sub (local.get 0) (i64.const 2))
- (i32.const 13)
- )
- (call_indirect (type $over-i64)
- (i64.sub (local.get 0) (i64.const 1))
- (i32.const 13)
+ (then
+ (i64.const 1)
+ )
+ (else
+ (i64.add
+ (call_indirect (type $over-i64)
+ (i64.sub (local.get 0) (i64.const 2))
+ (i32.const 13)
+ )
+ (call_indirect (type $over-i64)
+ (i64.sub (local.get 0) (i64.const 1))
+ (i32.const 13)
+ )
)
)
)
@@ -132,19 +140,27 @@
(func $even (export "even") (param i32) (result i32)
(if i32 (i32.eqz (local.get 0))
- (i32.const 44)
- (call_indirect (type $over-i32)
- (i32.sub (local.get 0) (i32.const 1))
- (i32.const 15)
+ (then
+ (i32.const 44)
+ )
+ (else
+ (call_indirect (type $over-i32)
+ (i32.sub (local.get 0) (i32.const 1))
+ (i32.const 15)
+ )
)
)
)
(func $odd (export "odd") (param i32) (result i32)
(if i32 (i32.eqz (local.get 0))
- (i32.const 99)
- (call_indirect (type $over-i32)
- (i32.sub (local.get 0) (i32.const 1))
- (i32.const 14)
+ (then
+ (i32.const 99)
+ )
+ (else
+ (call_indirect (type $over-i32)
+ (i32.sub (local.get 0) (i32.const 1))
+ (i32.const 14)
+ )
)
)
)
diff --git a/test/spec/old_float_exprs.wast b/test/spec/old_float_exprs.wast
index 854e21a62..c6e900f03 100644
--- a/test/spec/old_float_exprs.wast
+++ b/test/spec/old_float_exprs.wast
@@ -897,15 +897,15 @@
;; Test that x<y?x:y, etc. using if and else aren't folded to min, etc.
(module
- (func (export "f32.no_fold_lt_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.lt (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
- (func (export "f32.no_fold_le_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.le (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
- (func (export "f32.no_fold_gt_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.gt (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
- (func (export "f32.no_fold_ge_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.ge (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
+ (func (export "f32.no_fold_lt_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.lt (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
+ (func (export "f32.no_fold_le_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.le (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
+ (func (export "f32.no_fold_gt_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.gt (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
+ (func (export "f32.no_fold_ge_if") (param $x f32) (param $y f32) (result f32) (if f32 (f32.ge (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
- (func (export "f64.no_fold_lt_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.lt (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
- (func (export "f64.no_fold_le_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.le (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
- (func (export "f64.no_fold_gt_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.gt (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
- (func (export "f64.no_fold_ge_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.ge (local.get $x) (local.get $y)) (local.get $x) (local.get $y)))
+ (func (export "f64.no_fold_lt_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.lt (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
+ (func (export "f64.no_fold_le_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.le (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
+ (func (export "f64.no_fold_gt_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.gt (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
+ (func (export "f64.no_fold_ge_if") (param $x f64) (param $y f64) (result f64) (if f64 (f64.ge (local.get $x) (local.get $y)) (then (local.get $x) )(else (local.get $y))))
)
(assert_return (invoke "f32.no_fold_lt_if" (f32.const 0.0) (f32.const nan)) (f32.const nan))
@@ -991,15 +991,15 @@
;; Test that x<0?-x:0, etc. using if aren't folded to abs
(module
- (func (export "f32.no_fold_lt_if_to_abs") (param $x f32) (result f32) (if f32 (f32.lt (local.get $x) (f32.const 0.0)) (f32.neg (local.get $x)) (local.get $x)))
- (func (export "f32.no_fold_le_if_to_abs") (param $x f32) (result f32) (if f32 (f32.le (local.get $x) (f32.const -0.0)) (f32.neg (local.get $x)) (local.get $x)))
- (func (export "f32.no_fold_gt_if_to_abs") (param $x f32) (result f32) (if f32 (f32.gt (local.get $x) (f32.const -0.0)) (local.get $x) (f32.neg (local.get $x))))
- (func (export "f32.no_fold_ge_if_to_abs") (param $x f32) (result f32) (if f32 (f32.ge (local.get $x) (f32.const 0.0)) (local.get $x) (f32.neg (local.get $x))))
+ (func (export "f32.no_fold_lt_if_to_abs") (param $x f32) (result f32) (if f32 (f32.lt (local.get $x) (f32.const 0.0)) (then (f32.neg (local.get $x)) )(else (local.get $x))))
+ (func (export "f32.no_fold_le_if_to_abs") (param $x f32) (result f32) (if f32 (f32.le (local.get $x) (f32.const -0.0)) (then (f32.neg (local.get $x)) )(else (local.get $x))))
+ (func (export "f32.no_fold_gt_if_to_abs") (param $x f32) (result f32) (if f32 (f32.gt (local.get $x) (f32.const -0.0)) (then (local.get $x) )(else (f32.neg (local.get $x)))))
+ (func (export "f32.no_fold_ge_if_to_abs") (param $x f32) (result f32) (if f32 (f32.ge (local.get $x) (f32.const 0.0)) (then (local.get $x) )(else (f32.neg (local.get $x)))))
- (func (export "f64.no_fold_lt_if_to_abs") (param $x f64) (result f64) (if f64 (f64.lt (local.get $x) (f64.const 0.0)) (f64.neg (local.get $x)) (local.get $x)))
- (func (export "f64.no_fold_le_if_to_abs") (param $x f64) (result f64) (if f64 (f64.le (local.get $x) (f64.const -0.0)) (f64.neg (local.get $x)) (local.get $x)))
- (func (export "f64.no_fold_gt_if_to_abs") (param $x f64) (result f64) (if f64 (f64.gt (local.get $x) (f64.const -0.0)) (local.get $x) (f64.neg (local.get $x))))
- (func (export "f64.no_fold_ge_if_to_abs") (param $x f64) (result f64) (if f64 (f64.ge (local.get $x) (f64.const 0.0)) (local.get $x) (f64.neg (local.get $x))))
+ (func (export "f64.no_fold_lt_if_to_abs") (param $x f64) (result f64) (if f64 (f64.lt (local.get $x) (f64.const 0.0)) (then (f64.neg (local.get $x)) )(else (local.get $x))))
+ (func (export "f64.no_fold_le_if_to_abs") (param $x f64) (result f64) (if f64 (f64.le (local.get $x) (f64.const -0.0)) (then (f64.neg (local.get $x)) )(else (local.get $x))))
+ (func (export "f64.no_fold_gt_if_to_abs") (param $x f64) (result f64) (if f64 (f64.gt (local.get $x) (f64.const -0.0)) (then (local.get $x) )(else (f64.neg (local.get $x)))))
+ (func (export "f64.no_fold_ge_if_to_abs") (param $x f64) (result f64) (if f64 (f64.ge (local.get $x) (f64.const 0.0)) (then (local.get $x) )(else (f64.neg (local.get $x)))))
)
(assert_return (invoke "f32.no_fold_lt_if_to_abs" (f32.const nan:0x200000)) (f32.const nan:0x200000))
diff --git a/test/spec/old_unreachable.wast b/test/spec/old_unreachable.wast
index ee61f794f..a1d7934c1 100644
--- a/test/spec/old_unreachable.wast
+++ b/test/spec/old_unreachable.wast
@@ -81,13 +81,13 @@
)
(func (export "as-if-cond") (result i32)
- (if i32 (unreachable) (i32.const 0) (i32.const 1))
+ (if i32 (unreachable) (then (i32.const 0) )(else (i32.const 1)))
)
(func (export "as-if-then") (param i32 i32) (result i32)
- (if i32 (local.get 0) (unreachable) (local.get 1))
+ (if i32 (local.get 0) (then (unreachable) )(else (local.get 1)))
)
(func (export "as-if-else") (param i32 i32) (result i32)
- (if i32 (local.get 0) (local.get 1) (unreachable))
+ (if i32 (local.get 0) (then (local.get 1) )(else (unreachable)))
)
(func (export "as-select-first") (param i32 i32) (result i32)
diff --git a/test/spec/stack.wast b/test/spec/stack.wast
index d0c46955d..a8c79b698 100644
--- a/test/spec/stack.wast
+++ b/test/spec/stack.wast
@@ -34,15 +34,17 @@
(i64.eq)
(if
(then (br $done))
- (else
- (local.get $i)
- (local.get $res)
- (i64.mul)
- (local.set $res)
- (local.get $i)
- (i64.const 1)
- (i64.sub)
- (local.set $i)
+ (then
+ (else
+ (local.get $i)
+ (local.get $res)
+ (i64.mul)
+ (local.set $res)
+ (local.get $i)
+ (i64.const 1)
+ (i64.sub)
+ (local.set $i)
+ )
)
)
(br $loop)
@@ -91,11 +93,13 @@
(i64.eq (local.get $i) (i64.const 0))
(if
(then (br $done))
- (else
- (i64.mul (local.get $i) (local.get $res))
- (local.set $res)
- (i64.sub (local.get $i) (i64.const 1))
- (local.set $i)
+ (then
+ (else
+ (i64.mul (local.get $i) (local.get $res))
+ (local.set $res)
+ (i64.sub (local.get $i) (i64.const 1))
+ (local.set $i)
+ )
)
)
(br $loop)