Skip to content

Commit

Permalink
[test] Test that atypical folded if conditions are parsed correctly (#…
Browse files Browse the repository at this point in the history
…1682)

Check that the condition must be a sequence of folded (as opposed to unfolded)
instructions, but also check that having zero or multiple folded instructions is
allowed.
  • Loading branch information
tlively authored Sep 21, 2023
1 parent cf73a6d commit 0c5b9c0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/core/if.wast
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@
)
(drop) (drop) (drop)
)

;; Atypical folded condition syntax

(func (export "atypical-condition")
i32.const 0
(if (then) (else))
(if (i32.const 1) (i32.eqz) (then) (else))
)
)

(assert_return (invoke "empty" (i32.const 0)))
Expand Down Expand Up @@ -722,6 +730,8 @@

(assert_return (invoke "type-use"))

(assert_return (invoke "atypical-condition"))

(assert_malformed
(module quote
"(type $sig (func (param i32) (result i32)))"
Expand Down Expand Up @@ -1547,4 +1557,8 @@
(assert_malformed
(module quote "(func i32.const 0 if $a else $l end $l)")
"mismatching label"
)
(assert_malformed
(module quote "(func (if i32.const 0 (then) (else)))")
"unexpected token"
)

0 comments on commit 0c5b9c0

Please sign in to comment.