Skip to content

Commit

Permalink
[test] Add tests for return_call(_indirect) in try (#275)
Browse files Browse the repository at this point in the history
This adds tests of `return_call(_indirect)`s within `try`s. Because this
repo's interpreter doesn't have the tail call support, this requires
 #274 to be merged before merging.

These test also needs `--experimental-wasm-return_call` to `node`
argument in the CI to pass.
  • Loading branch information
aheejin authored Apr 23, 2023
1 parent e15eb41 commit 36a364c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
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
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

0 comments on commit 36a364c

Please sign in to comment.