-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unfolded versions of the legacy (v3) exception-handling tests (#1672
- Loading branch information
Showing
17 changed files
with
2,678 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
;; Test rethrow instruction. | ||
|
||
(module | ||
(tag $e0) | ||
(tag $e1) | ||
|
||
(func (export "catch-rethrow-0") | ||
try | ||
throw $e0 | ||
catch $e0 | ||
rethrow 0 | ||
end | ||
) | ||
|
||
(func (export "catch-rethrow-1") (param i32) (result i32) | ||
try (result i32) | ||
throw $e0 | ||
catch $e0 | ||
local.get 0 | ||
i32.eqz | ||
if | ||
rethrow 1 | ||
end | ||
i32.const 23 | ||
end | ||
) | ||
|
||
(func (export "catchall-rethrow-0") | ||
try | ||
throw $e0 | ||
catch_all | ||
rethrow 0 | ||
end | ||
) | ||
|
||
(func (export "catchall-rethrow-1") (param i32) (result i32) | ||
try (result i32) | ||
throw $e0 | ||
catch_all | ||
local.get 0 | ||
i32.eqz | ||
if | ||
rethrow 1 | ||
end | ||
i32.const 23 | ||
end | ||
) | ||
|
||
(func (export "rethrow-nested") (param i32) (result i32) | ||
try (result i32) | ||
throw $e1 | ||
catch $e1 | ||
try (result i32) | ||
throw $e0 | ||
catch $e0 | ||
local.get 0 | ||
i32.const 0 | ||
i32.eq | ||
if | ||
rethrow 1 | ||
end | ||
local.get 0 | ||
i32.const 1 | ||
i32.eq | ||
if | ||
rethrow 2 | ||
end | ||
i32.const 23 | ||
end | ||
end | ||
) | ||
|
||
(func (export "rethrow-recatch") (param i32) (result i32) | ||
try (result i32) | ||
throw $e0 | ||
catch $e0 | ||
try (result i32) | ||
local.get 0 | ||
i32.eqz | ||
if | ||
rethrow 2 | ||
end | ||
i32.const 42 | ||
catch $e0 | ||
i32.const 23 | ||
end | ||
end | ||
) | ||
|
||
(func (export "rethrow-stack-polymorphism") | ||
try | ||
throw $e0 | ||
catch $e0 | ||
i32.const 1 | ||
rethrow 0 | ||
end | ||
) | ||
) | ||
|
||
(assert_exception (invoke "catch-rethrow-0")) | ||
|
||
(assert_exception (invoke "catch-rethrow-1" (i32.const 0))) | ||
(assert_return (invoke "catch-rethrow-1" (i32.const 1)) (i32.const 23)) | ||
|
||
(assert_exception (invoke "catchall-rethrow-0")) | ||
|
||
(assert_exception (invoke "catchall-rethrow-1" (i32.const 0))) | ||
(assert_return (invoke "catchall-rethrow-1" (i32.const 1)) (i32.const 23)) | ||
(assert_exception (invoke "rethrow-nested" (i32.const 0))) | ||
(assert_exception (invoke "rethrow-nested" (i32.const 1))) | ||
(assert_return (invoke "rethrow-nested" (i32.const 2)) (i32.const 23)) | ||
|
||
(assert_return (invoke "rethrow-recatch" (i32.const 0)) (i32.const 23)) | ||
(assert_return (invoke "rethrow-recatch" (i32.const 1)) (i32.const 42)) | ||
|
||
(assert_exception (invoke "rethrow-stack-polymorphism")) | ||
|
||
(assert_invalid (module (func (rethrow 0))) "invalid rethrow label") | ||
(assert_invalid (module (func (block (rethrow 0)))) "invalid rethrow label") | ||
(assert_invalid (module (func | ||
try | ||
rethrow 0 | ||
delegate 0)) | ||
"invalid rethrow label") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
;; Test throw instruction. | ||
|
||
(module | ||
(tag $e0) | ||
(tag $e-i32 (param i32)) | ||
(tag $e-f32 (param f32)) | ||
(tag $e-i64 (param i64)) | ||
(tag $e-f64 (param f64)) | ||
(tag $e-i32-i32 (param i32 i32)) | ||
|
||
(func $throw-if (export "throw-if") (param i32) (result i32) | ||
(local.get 0) | ||
(i32.const 0) (if (i32.ne) (then (throw $e0))) | ||
(i32.const 0) | ||
) | ||
|
||
(func (export "throw-param-f32") (param f32) (local.get 0) (throw $e-f32)) | ||
|
||
(func (export "throw-param-i64") (param i64) (local.get 0) (throw $e-i64)) | ||
|
||
(func (export "throw-param-f64") (param f64) (local.get 0) (throw $e-f64)) | ||
|
||
(func $throw-1-2 (i32.const 1) (i32.const 2) (throw $e-i32-i32)) | ||
(func (export "test-throw-1-2") | ||
try | ||
call $throw-1-2 | ||
catch $e-i32-i32 | ||
i32.const 2 | ||
i32.ne | ||
if | ||
unreachable | ||
end | ||
i32.const 1 | ||
i32.ne | ||
if | ||
unreachable | ||
end | ||
end | ||
) | ||
) | ||
|
||
(assert_return (invoke "throw-if" (i32.const 0)) (i32.const 0)) | ||
(assert_exception (invoke "throw-if" (i32.const 10))) | ||
(assert_exception (invoke "throw-if" (i32.const -1))) | ||
|
||
(assert_exception (invoke "throw-param-f32" (f32.const 5.0))) | ||
(assert_exception (invoke "throw-param-i64" (i64.const 5))) | ||
(assert_exception (invoke "throw-param-f64" (f64.const 5.0))) | ||
|
||
(assert_return (invoke "test-throw-1-2")) | ||
|
||
(assert_invalid (module (func (throw 0))) "unknown tag 0") | ||
(assert_invalid (module (tag (param i32)) (func (throw 0))) | ||
"type mismatch: instruction requires [i32] but stack has []") | ||
(assert_invalid (module (tag (param i32)) (func (i64.const 5) (throw 0))) | ||
"type mismatch: instruction requires [i32] but stack has [i64]") |
Oops, something went wrong.