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 all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-interpreter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- name: Build interpreter
run: cd interpreter && opam exec make
- name: Run tests
run: cd interpreter && opam exec make JS=node ci
run: cd interpreter && opam exec make JS='node --experimental-wasm-return_call' ci
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was necessary to make the interpreter tests pass, because we not only run them with ocaml but also with JS. I think we can revert this later once the tail call is merged to the main spec and is enabled without a flag.

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