Skip to content

Commit d12dc35

Browse files
committed
Test breaking out of a try
1 parent 36a364c commit d12dc35

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

test/core/try_catch.wast

+11
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@
167167
(catch $e0)
168168
)
169169
)
170+
171+
(func (export "break-try-catch")
172+
(try (do (br 0)) (catch $e0))
173+
)
174+
175+
(func (export "break-try-catch_all")
176+
(try (do (br 0)) (catch_all))
177+
)
170178
)
171179

172180
(assert_return (invoke "empty-catch"))
@@ -211,6 +219,9 @@
211219
(assert_exception (invoke "return-call-in-try-catch"))
212220
(assert_exception (invoke "return-call-indirect-in-try-catch"))
213221

222+
(assert_return (invoke "break-try-catch"))
223+
(assert_return (invoke "break-try-catch_all"))
224+
214225
(module
215226
(func $imported-throw (import "test" "throw"))
216227
(tag $e0)

test/core/try_delegate.wast

+45
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,46 @@
145145
(catch $e0)
146146
)
147147
)
148+
149+
(func (export "break-try-delegate")
150+
(try (do (br 0)) (delegate 0))
151+
)
152+
153+
(func (export "break-and-call-throw") (result i32)
154+
(try $outer (result i32)
155+
(do
156+
(try (result i32)
157+
(do
158+
(block $a
159+
(try (do (br $a)) (delegate $outer))
160+
)
161+
(call $throw-void)
162+
(i32.const 0)
163+
)
164+
(catch $e0 (i32.const 1))
165+
)
166+
)
167+
(catch $e0 (i32.const 2))
168+
)
169+
)
170+
171+
(func (export "break-and-throw") (result i32)
172+
(try $outer (result i32)
173+
(do
174+
(try (result i32)
175+
(do
176+
(block $a
177+
(try (do (br $a)) (delegate $outer))
178+
)
179+
(throw $e0)
180+
(i32.const 0)
181+
)
182+
(catch $e0 (i32.const 1))
183+
)
184+
)
185+
(catch $e0 (i32.const 2))
186+
)
187+
)
148188
)
149189

150190
(assert_return (invoke "delegate-no-throw") (i32.const 1))
@@ -173,6 +213,11 @@
173213
(assert_exception (invoke "return-call-in-try-delegate"))
174214
(assert_exception (invoke "return-call-indirect-in-try-delegate"))
175215

216+
(assert_return (invoke "break-try-delegate"))
217+
218+
(assert_return (invoke "break-and-call-throw") (i32.const 1))
219+
(assert_return (invoke "break-and-throw") (i32.const 1))
220+
176221
(assert_malformed
177222
(module quote "(module (func (delegate 0)))")
178223
"unexpected token"

0 commit comments

Comments
 (0)