Skip to content

Commit

Permalink
[test] Improve test coverage (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
Honry authored and rossberg committed Nov 7, 2018
1 parent a56cf2e commit 5aaea96
Show file tree
Hide file tree
Showing 8 changed files with 955 additions and 1 deletion.
51 changes: 50 additions & 1 deletion test/core/br_if.wast
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,36 @@
)
)

(memory 1)
(func (export "as-load-address") (result i32)
(block (result i32) (i32.load (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-loadN-address") (result i32)
(block (result i32) (i32.load8_s (br_if 0 (i32.const 30) (i32.const 1))))
)

(func (export "as-store-address") (result i32)
(block (result i32)
(i32.store (br_if 0 (i32.const 30) (i32.const 1)) (i32.const 7)) (i32.const -1)
)
)
(func (export "as-store-value") (result i32)
(block (result i32)
(i32.store (i32.const 2) (br_if 0 (i32.const 31) (i32.const 1))) (i32.const -1)
)
)

(func (export "as-storeN-address") (result i32)
(block (result i32)
(i32.store8 (br_if 0 (i32.const 32) (i32.const 1)) (i32.const 7)) (i32.const -1)
)
)
(func (export "as-storeN-value") (result i32)
(block (result i32)
(i32.store16 (i32.const 2) (br_if 0 (i32.const 33) (i32.const 1))) (i32.const -1)
)
)

(func (export "as-unary-operand") (result f64)
(block (result f64) (f64.neg (br_if 0 (f64.const 1.0) (i32.const 1))))
)
Expand All @@ -228,8 +258,16 @@
(func (export "as-binary-right") (result i32)
(block (result i32) (i32.sub (i32.const 10) (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-test-operand") (result i32)
(block (result i32) (i32.eqz (br_if 0 (i32.const 0) (i32.const 1))))
)
(func (export "as-compare-left") (result i32)
(block (result i32) (i32.le_u (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
)
(func (export "as-compare-right") (result i32)
(block (result i32) (i32.ne (i32.const 10) (br_if 0 (i32.const 1) (i32.const 42))))
)

(memory 0)
(func (export "as-memory.grow-size") (result i32)
(block (result i32) (memory.grow (br_if 0 (i32.const 1) (i32.const 1))))
)
Expand Down Expand Up @@ -410,9 +448,20 @@
(assert_return (invoke "as-set_global-value" (i32.const 0)) (i32.const -1))
(assert_return (invoke "as-set_global-value" (i32.const 1)) (i32.const 1))

(assert_return (invoke "as-load-address") (i32.const 1))
(assert_return (invoke "as-loadN-address") (i32.const 30))

(assert_return (invoke "as-store-address") (i32.const 30))
(assert_return (invoke "as-store-value") (i32.const 31))
(assert_return (invoke "as-storeN-address") (i32.const 32))
(assert_return (invoke "as-storeN-value") (i32.const 33))

(assert_return (invoke "as-unary-operand") (f64.const 1.0))
(assert_return (invoke "as-binary-left") (i32.const 1))
(assert_return (invoke "as-binary-right") (i32.const 1))
(assert_return (invoke "as-test-operand") (i32.const 0))
(assert_return (invoke "as-compare-left") (i32.const 1))
(assert_return (invoke "as-compare-right") (i32.const 1))
(assert_return (invoke "as-memory.grow-size") (i32.const 1))

(assert_return (invoke "nested-block-value" (i32.const 0)) (i32.const 21))
Expand Down
36 changes: 36 additions & 0 deletions test/core/call.wast
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,34 @@
(func (export "as-load-operand") (result i32)
(i32.load (call $const-i32))
)

(func $dummy (param i32) (result i32) (get_local 0))
(func $du (param f32) (result f32) (get_local 0))
(func (export "as-unary-operand") (result f32)
(block (result f32) (f32.sqrt (call $du (f32.const 0x0p+0))))
)

(func (export "as-binary-left") (result i32)
(block (result i32) (i32.add (call $dummy (i32.const 1)) (i32.const 10)))
)
(func (export "as-binary-right") (result i32)
(block (result i32) (i32.sub (i32.const 10) (call $dummy (i32.const 1))))
)

(func (export "as-test-operand") (result i32)
(block (result i32) (i32.eqz (call $dummy (i32.const 1))))
)

(func (export "as-compare-left") (result i32)
(block (result i32) (i32.le_u (call $dummy (i32.const 1)) (i32.const 10)))
)
(func (export "as-compare-right") (result i32)
(block (result i32) (i32.ne (i32.const 10) (call $dummy (i32.const 1))))
)

(func (export "as-convert-operand") (result i64)
(block (result i64) (i64.extend_s/i32 (call $dummy (i32.const 1))))
)
)

(assert_return (invoke "type-i32") (i32.const 0x132))
Expand Down Expand Up @@ -272,6 +300,14 @@
(assert_return (invoke "as-set_global-value") (i32.const 0x132))
(assert_return (invoke "as-load-operand") (i32.const 1))

(assert_return (invoke "as-unary-operand") (f32.const 0x0p+0))
(assert_return (invoke "as-binary-left") (i32.const 11))
(assert_return (invoke "as-binary-right") (i32.const 9))
(assert_return (invoke "as-test-operand") (i32.const 0))
(assert_return (invoke "as-compare-left") (i32.const 1))
(assert_return (invoke "as-compare-right") (i32.const 1))
(assert_return (invoke "as-convert-operand") (i64.const 1))

;; Invalid typing

(assert_invalid
Expand Down
67 changes: 67 additions & 0 deletions test/core/call_indirect.wast
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,65 @@
(func (export "as-load-operand") (result i32)
(i32.load (call_indirect (type $out-i32) (i32.const 0)))
)

(func (export "as-unary-operand") (result f32)
(block (result f32)
(f32.sqrt
(call_indirect (type $over-f32) (f32.const 0x0p+0) (i32.const 6))
)
)
)

(func (export "as-binary-left") (result i32)
(block (result i32)
(i32.add
(call_indirect (type $over-i32) (i32.const 1) (i32.const 4))
(i32.const 10)
)
)
)
(func (export "as-binary-right") (result i32)
(block (result i32)
(i32.sub
(i32.const 10)
(call_indirect (type $over-i32) (i32.const 1) (i32.const 4))
)
)
)

(func (export "as-test-operand") (result i32)
(block (result i32)
(i32.eqz
(call_indirect (type $over-i32) (i32.const 1) (i32.const 4))
)
)
)

(func (export "as-compare-left") (result i32)
(block (result i32)
(i32.le_u
(call_indirect (type $over-i32) (i32.const 1) (i32.const 4))
(i32.const 10)
)
)
)
(func (export "as-compare-right") (result i32)
(block (result i32)
(i32.ne
(i32.const 10)
(call_indirect (type $over-i32) (i32.const 1) (i32.const 4))
)
)
)

(func (export "as-convert-operand") (result i64)
(block (result i64)
(i64.extend_s/i32
(call_indirect (type $over-i32) (i32.const 1) (i32.const 4))
)
)
)

)

(assert_return (invoke "type-i32") (i32.const 0x132))
Expand Down Expand Up @@ -521,6 +580,14 @@
(assert_return (invoke "as-set_global-value") (f64.const 1.0))
(assert_return (invoke "as-load-operand") (i32.const 1))

(assert_return (invoke "as-unary-operand") (f32.const 0x0p+0))
(assert_return (invoke "as-binary-left") (i32.const 11))
(assert_return (invoke "as-binary-right") (i32.const 9))
(assert_return (invoke "as-test-operand") (i32.const 0))
(assert_return (invoke "as-compare-left") (i32.const 1))
(assert_return (invoke "as-compare-right") (i32.const 1))
(assert_return (invoke "as-convert-operand") (i64.const 1))

;; Invalid syntax

(assert_malformed
Expand Down
Loading

0 comments on commit 5aaea96

Please sign in to comment.