From 2fdf42769dab0067a1b981fd9fb1a4f8e6046289 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sat, 21 Sep 2024 21:12:44 -0300 Subject: [PATCH] Add setjmp bait --- test/legacy/exceptions/core/try_catch.wast | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/legacy/exceptions/core/try_catch.wast b/test/legacy/exceptions/core/try_catch.wast index 07399f3a..08936af7 100644 --- a/test/legacy/exceptions/core/try_catch.wast +++ b/test/legacy/exceptions/core/try_catch.wast @@ -175,6 +175,20 @@ (func (export "break-try-catch_all") (try (do (br 0)) (catch_all)) ) + + (func $longjmp-bait (throw $e0)) + (func (export "setjmp-bait") (param $return-early i32) (result i32) + (local $value i32) + (try $try + (do + (br_if $try (local.get $return-early)) + (local.set $value (i32.const 1)) + (call $longjmp-bait) + ) + (catch $e0) + ) + (local.get $value) + ) ) (assert_return (invoke "empty-catch")) @@ -222,6 +236,9 @@ (assert_return (invoke "break-try-catch")) (assert_return (invoke "break-try-catch_all")) +(assert_return (invoke "setjmp-bait" (i32.const 1)) (i32.const 0)) +(assert_return (invoke "setjmp-bait" (i32.const 0)) (i32.const 1)) + (module (func $imported-throw (import "test" "throw")) (tag $e0)