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

Commit 36a364c

Browse files
authored
[test] Add tests for return_call(_indirect) in try (#275)
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.
1 parent e15eb41 commit 36a364c

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

.github/workflows/ci-interpreter.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
- name: Build interpreter
3232
run: cd interpreter && opam exec make
3333
- name: Run tests
34-
run: cd interpreter && opam exec make JS=node ci
34+
run: cd interpreter && opam exec make JS='node --experimental-wasm-return_call' ci

test/core/try_catch.wast

+23
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@
147147
(catch $e0 (i32.const 1))
148148
)
149149
)
150+
151+
(func $throw-void (throw $e0))
152+
(func (export "return-call-in-try-catch")
153+
(try
154+
(do
155+
(return_call $throw-void)
156+
)
157+
(catch $e0)
158+
)
159+
)
160+
161+
(table funcref (elem $throw-void))
162+
(func (export "return-call-indirect-in-try-catch")
163+
(try
164+
(do
165+
(return_call_indirect (param) (i32.const 0))
166+
)
167+
(catch $e0)
168+
)
169+
)
150170
)
151171

152172
(assert_return (invoke "empty-catch"))
@@ -188,6 +208,9 @@
188208
(assert_return (invoke "catchless-try" (i32.const 0)) (i32.const 0))
189209
(assert_return (invoke "catchless-try" (i32.const 1)) (i32.const 1))
190210

211+
(assert_exception (invoke "return-call-in-try-catch"))
212+
(assert_exception (invoke "return-call-indirect-in-try-catch"))
213+
191214
(module
192215
(func $imported-throw (import "test" "throw"))
193216
(tag $e0)

test/core/try_delegate.wast

+33
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,36 @@
115115
(delegate $l3))))
116116
unreachable)
117117
(catch_all (i32.const 1))))
118+
119+
(func $throw-void (throw $e0))
120+
(func (export "return-call-in-try-delegate")
121+
(try $l
122+
(do
123+
(try
124+
(do
125+
(return_call $throw-void)
126+
)
127+
(delegate $l)
128+
)
129+
)
130+
(catch $e0)
131+
)
132+
)
133+
134+
(table funcref (elem $throw-void))
135+
(func (export "return-call-indirect-in-try-delegate")
136+
(try $l
137+
(do
138+
(try
139+
(do
140+
(return_call_indirect (param) (i32.const 0))
141+
)
142+
(delegate $l)
143+
)
144+
)
145+
(catch $e0)
146+
)
147+
)
118148
)
119149

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

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

173+
(assert_exception (invoke "return-call-in-try-delegate"))
174+
(assert_exception (invoke "return-call-indirect-in-try-delegate"))
175+
143176
(assert_malformed
144177
(module quote "(module (func (delegate 0)))")
145178
"unexpected token"

0 commit comments

Comments
 (0)