Skip to content

Commit 6d0ab8b

Browse files
tlivelyrossberg
authored andcommitted
[test] Test that atypical folded if conditions are parsed correctly (#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.
1 parent a994f2d commit 6d0ab8b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/core/if.wast

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@
524524
)
525525
(drop) (drop) (drop)
526526
)
527+
528+
;; Atypical folded condition syntax
529+
530+
(func (export "atypical-condition")
531+
i32.const 0
532+
(if (then) (else))
533+
(if (i32.const 1) (i32.eqz) (then) (else))
534+
)
527535
)
528536

529537
(assert_return (invoke "empty" (i32.const 0)))
@@ -722,6 +730,8 @@
722730

723731
(assert_return (invoke "type-use"))
724732

733+
(assert_return (invoke "atypical-condition"))
734+
725735
(assert_malformed
726736
(module quote
727737
"(type $sig (func (param i32) (result i32)))"
@@ -1548,3 +1558,7 @@
15481558
(module quote "(func i32.const 0 if $a else $l end $l)")
15491559
"mismatching label"
15501560
)
1561+
(assert_malformed
1562+
(module quote "(func (if i32.const 0 (then) (else)))")
1563+
"unexpected token"
1564+
)

0 commit comments

Comments
 (0)