@@ -258,11 +258,12 @@ let _ = Tag.add_tag wasm_mod "foo" Type.int32 Type.none
258258let _ = Tag. add_tag wasm_mod " bar" Type. int32 Type. none
259259
260260(* Exception handling *)
261+ let body =
262+ Expression.Throw. make wasm_mod " foo"
263+ [ Expression.Const. make wasm_mod (Literal. int32 1l ) ]
264+
261265let try_catch_1 =
262- Expression.Try. make wasm_mod (Some " tc1" )
263- (Expression.Throw. make wasm_mod " foo"
264- [ Expression.Const. make wasm_mod (Literal. int32 1l ) ])
265- [ " foo" ; " bar" ]
266+ Expression.Try. make wasm_mod (Some " tc1" ) body [ " foo" ; " bar" ]
266267 [
267268 Expression.Block. make wasm_mod " tc1blk2"
268269 [
@@ -279,6 +280,19 @@ let try_catch_1 =
279280 ]
280281 None
281282
283+ let _ = assert (Expression.Try. get_name try_catch_1 = Some " tc1" )
284+ let _ = Expression.Try. set_name try_catch_1 " renamed_tc1"
285+ let _ = assert (Expression.Try. get_name try_catch_1 = Some " renamed_tc1" )
286+ let _ = Expression.Try. set_name try_catch_1 " tc1"
287+
288+ let _ =
289+ assert (
290+ Expression. get_kind (Expression.Try. get_body try_catch_1)
291+ = Expression. get_kind body)
292+
293+ let _ = assert (Expression.Try_Catch. get_num_catch_tags try_catch_1 = 2 )
294+ let _ = assert (Expression.Try_Catch. get_num_catch_bodies try_catch_1 = 2 )
295+
282296let try_catch_2 =
283297 Expression.Try_Catch. make wasm_mod (Some " tc2" )
284298 (Expression.Throw. make wasm_mod " foo"
@@ -299,6 +313,8 @@ let try_catch_2 =
299313 ];
300314 ]
301315
316+ let _ = assert (Expression.Try_Catch. get_name try_catch_2 = Some " tc2" )
317+
302318(* One more catch-body than catch-tag; last body becomes the catch_all *)
303319let try_catch_all_1 =
304320 Expression.Try. make wasm_mod (Some " tc3" )
0 commit comments