Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

[test] Add tests for return_call(_indirect) in try #275

Merged
merged 6 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions test/core/try_catch.wast
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@
(catch $e0 (i32.const 1))
)
)

(func $throw-void (throw $e0))
(func (export "return-call-in-try-catch")
(try
(do
(return_call $throw-void)
)
(catch $e0)
)
)

(table funcref (elem $throw-void))
(func (export "return-call-indirect-in-try-catch")
(try
(do
(return_call_indirect (param) (i32.const 0))
)
(catch $e0)
)
)
)

(assert_return (invoke "empty-catch"))
Expand Down Expand Up @@ -188,6 +208,9 @@
(assert_return (invoke "catchless-try" (i32.const 0)) (i32.const 0))
(assert_return (invoke "catchless-try" (i32.const 1)) (i32.const 1))

(assert_exception (invoke "return-call-in-try-catch"))
(assert_exception (invoke "return-call-indirect-in-try-catch"))

(module
(func $imported-throw (import "test" "throw"))
(tag $e0)
Expand Down
33 changes: 33 additions & 0 deletions test/core/try_delegate.wast
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,36 @@
(delegate $l3))))
unreachable)
(catch_all (i32.const 1))))

(func $throw-void (throw $e0))
(func (export "return-call-in-try-delegate")
(try $l
(do
(try
(do
(return_call $throw-void)
)
(delegate $l)
)
)
(catch $e0)
)
)

(table funcref (elem $throw-void))
(func (export "return-call-indirect-in-try-delegate")
(try $l
(do
(try
(do
(return_call_indirect (param) (i32.const 0))
)
(delegate $l)
)
)
(catch $e0)
)
)
)

(assert_return (invoke "delegate-no-throw") (i32.const 1))
Expand All @@ -140,6 +170,9 @@

(assert_return (invoke "delegate-correct-targets") (i32.const 1))

(assert_exception (invoke "return-call-in-try-delegate"))
(assert_exception (invoke "return-call-indirect-in-try-delegate"))

(assert_malformed
(module quote "(module (func (delegate 0)))")
"unexpected token"
Expand Down