summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/exception-handling.wast26
-rw-r--r--test/exception-handling.wast.from-wast28
-rw-r--r--test/exception-handling.wast.fromBinary32
-rw-r--r--test/exception-handling.wast.fromBinary.noDebugInfo32
-rw-r--r--test/lit/passes/inlining-eh.wast8
-rw-r--r--test/lit/passes/remove-unused-names-eh.wast4
-rw-r--r--test/spec/exception-handling.wast200
7 files changed, 322 insertions, 8 deletions
diff --git a/test/exception-handling.wast b/test/exception-handling.wast
index c608e860a..cd436296b 100644
--- a/test/exception-handling.wast
+++ b/test/exception-handling.wast
@@ -2,6 +2,7 @@
(tag $e-i32 (param i32))
(tag $e-i64 (param i64))
(tag $e-i32-i64 (param i32 i64))
+ (tag $e-anyref (param anyref))
(tag $e-empty)
(func $foo)
@@ -311,4 +312,29 @@
)
)
)
+
+ (func $pop_test
+ (try
+ (do)
+ (catch $e-i32
+ (throw $e-i32
+ (if (result i32)
+ ;; pop is within an if condition, so this is OK.
+ (pop i32)
+ (i32.const 0)
+ (i32.const 3)
+ )
+ )
+ )
+ )
+
+ (try
+ (do)
+ (catch $e-anyref
+ (drop
+ (pop funcref) ;; pop can be subtype
+ )
+ )
+ )
+ )
)
diff --git a/test/exception-handling.wast.from-wast b/test/exception-handling.wast.from-wast
index 1ce7a84b7..ee409652b 100644
--- a/test/exception-handling.wast.from-wast
+++ b/test/exception-handling.wast.from-wast
@@ -3,9 +3,11 @@
(type $i32_=>_none (func (param i32)))
(type $i64_=>_none (func (param i64)))
(type $i32_i64_=>_none (func (param i32 i64)))
+ (type $anyref_=>_none (func (param anyref)))
(tag $e-i32 (param i32))
(tag $e-i64 (param i64))
(tag $e-i32-i64 (param i32 i64))
+ (tag $e-anyref (param anyref))
(tag $e-empty (param))
(func $foo
(nop)
@@ -351,4 +353,30 @@
)
)
)
+ (func $pop_test
+ (try $try
+ (do
+ (nop)
+ )
+ (catch $e-i32
+ (throw $e-i32
+ (if (result i32)
+ (pop i32)
+ (i32.const 0)
+ (i32.const 3)
+ )
+ )
+ )
+ )
+ (try $try28
+ (do
+ (nop)
+ )
+ (catch $e-anyref
+ (drop
+ (pop funcref)
+ )
+ )
+ )
+ )
)
diff --git a/test/exception-handling.wast.fromBinary b/test/exception-handling.wast.fromBinary
index d37f48a23..9a89a0beb 100644
--- a/test/exception-handling.wast.fromBinary
+++ b/test/exception-handling.wast.fromBinary
@@ -3,10 +3,12 @@
(type $i32_=>_none (func (param i32)))
(type $i64_=>_none (func (param i64)))
(type $i32_i64_=>_none (func (param i32 i64)))
+ (type $anyref_=>_none (func (param anyref)))
(tag $tag$0 (param i32))
(tag $tag$1 (param i64))
(tag $tag$2 (param i32 i64))
- (tag $tag$3 (param))
+ (tag $tag$3 (param anyref))
+ (tag $tag$4 (param))
(func $foo
(nop)
)
@@ -269,7 +271,7 @@
(do
(nop)
)
- (catch $tag$3
+ (catch $tag$4
(nop)
)
)
@@ -380,5 +382,31 @@
)
)
)
+ (func $pop_test
+ (try $label$5
+ (do
+ (nop)
+ )
+ (catch $tag$0
+ (throw $tag$0
+ (if (result i32)
+ (pop i32)
+ (i32.const 0)
+ (i32.const 3)
+ )
+ )
+ )
+ )
+ (try $label$8
+ (do
+ (nop)
+ )
+ (catch $tag$3
+ (drop
+ (pop anyref)
+ )
+ )
+ )
+ )
)
diff --git a/test/exception-handling.wast.fromBinary.noDebugInfo b/test/exception-handling.wast.fromBinary.noDebugInfo
index 1a36aaa66..eb6b98bd8 100644
--- a/test/exception-handling.wast.fromBinary.noDebugInfo
+++ b/test/exception-handling.wast.fromBinary.noDebugInfo
@@ -3,10 +3,12 @@
(type $i32_=>_none (func (param i32)))
(type $i64_=>_none (func (param i64)))
(type $i32_i64_=>_none (func (param i32 i64)))
+ (type $anyref_=>_none (func (param anyref)))
(tag $tag$0 (param i32))
(tag $tag$1 (param i64))
(tag $tag$2 (param i32 i64))
- (tag $tag$3 (param))
+ (tag $tag$3 (param anyref))
+ (tag $tag$4 (param))
(func $0
(nop)
)
@@ -269,7 +271,7 @@
(do
(nop)
)
- (catch $tag$3
+ (catch $tag$4
(nop)
)
)
@@ -380,5 +382,31 @@
)
)
)
+ (func $5
+ (try $label$5
+ (do
+ (nop)
+ )
+ (catch $tag$0
+ (throw $tag$0
+ (if (result i32)
+ (pop i32)
+ (i32.const 0)
+ (i32.const 3)
+ )
+ )
+ )
+ )
+ (try $label$8
+ (do
+ (nop)
+ )
+ (catch $tag$3
+ (drop
+ (pop anyref)
+ )
+ )
+ )
+ )
)
diff --git a/test/lit/passes/inlining-eh.wast b/test/lit/passes/inlining-eh.wast
index 5ec3c55dc..ea49c9550 100644
--- a/test/lit/passes/inlining-eh.wast
+++ b/test/lit/passes/inlining-eh.wast
@@ -11,7 +11,9 @@
(try $label
(do)
(catch $tag$0
- (nop)
+ (drop
+ (pop i32)
+ )
)
)
)
@@ -27,7 +29,9 @@
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
;; CHECK-NEXT: (catch $tag$0
- ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (pop i32)
+ ;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
diff --git a/test/lit/passes/remove-unused-names-eh.wast b/test/lit/passes/remove-unused-names-eh.wast
index fcdbf0f07..e7a26cbae 100644
--- a/test/lit/passes/remove-unused-names-eh.wast
+++ b/test/lit/passes/remove-unused-names-eh.wast
@@ -10,7 +10,7 @@
;; CHECK-NEXT: (do
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (catch $tag$0
+ ;; CHECK-NEXT: (catch_all
;; CHECK-NEXT: (try $label$8
;; CHECK-NEXT: (do
;; CHECK-NEXT: (try
@@ -32,7 +32,7 @@
(func $func0
(try $label$9 ;; needed due to a rethrow
(do)
- (catch $tag$0
+ (catch_all
(try $label$8 ;; needed due to a delegate
(do
(try $label$6 ;; this one is not needed
diff --git a/test/spec/exception-handling.wast b/test/spec/exception-handling.wast
index 1b7907474..33454f1f9 100644
--- a/test/spec/exception-handling.wast
+++ b/test/spec/exception-handling.wast
@@ -191,6 +191,7 @@
)
)
(catch $e-i32
+ (drop (pop i32))
(rethrow $l0) ;; rethrow (i32.const 1) again
)
)
@@ -232,6 +233,7 @@
(assert_invalid
(module
+ (tag $e-i32 (param i32))
(func $f0
(try
(do (i32.const 0))
@@ -329,3 +331,201 @@
)
"all rethrow targets must be valid"
)
+
+(assert_invalid
+ (module
+ (func $f0
+ (try
+ (do)
+ (catch $e)
+ )
+ )
+ )
+ "catch's tag name is invalid: e"
+)
+
+(assert_invalid
+ (module
+ (tag $e-none (param))
+ (func $f0 (result i32)
+ (try (result i32)
+ (do
+ (i32.const 0)
+ )
+ (catch $e-none
+ (pop i32)
+ )
+ )
+ )
+ )
+ "catch's tag (e-none) doesn't have any params, but there are pops"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0
+ (try
+ (do)
+ (catch $e-i32)
+ )
+ )
+ )
+ "catch's tag (e-i32) has params, so there should be a single pop within the catch body"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0
+ (try
+ (do)
+ (catch $e-i32
+ (drop
+ (pop i32)
+ )
+ (drop
+ (pop i32)
+ )
+ )
+ )
+ )
+ )
+ "catch's tag (e-i32) has params, so there should be a single pop within the catch body"
+)
+
+(assert_invalid
+ (module
+ (func $f0 (result i32)
+ (try (result i32)
+ (do
+ (i32.const 0)
+ )
+ (catch_all
+ (pop i32)
+ )
+ )
+ )
+ )
+ "catch_all's body should not have pops"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0 (result f32)
+ (try (result f32)
+ (do
+ (f32.const 0)
+ )
+ (catch $e-i32
+ (pop f32)
+ )
+ )
+ )
+ )
+ "catch's tag (e-i32)'s pop doesn't have the same type as the tag's params"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0 (result i32)
+ (try (result i32)
+ (do
+ (i32.const 0)
+ )
+ (catch $e-i32
+ (drop
+ (i32.const 0)
+ )
+ (pop i32) ;; Not the first children within 'catch'
+ )
+ )
+ )
+ )
+ "catch's body (e-i32)'s pop's location is not valid"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0
+ (try
+ (do)
+ (catch $e-i32
+ (throw $e-i32
+ (block (result i32)
+ (pop i32) ;; pop is within a block
+ )
+ )
+ )
+ )
+ )
+ )
+ "catch's body (e-i32)'s pop's location is not valid"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0
+ (try
+ (do)
+ (catch $e-i32
+ (throw $e-i32
+ (loop (result i32)
+ (pop i32) ;; pop is within a loop
+ )
+ )
+ )
+ )
+ )
+ )
+ "catch's body (e-i32)'s pop's location is not valid"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0
+ (try
+ (do)
+ (catch $e-i32
+ (throw $e-i32
+ (try (result i32)
+ (do
+ (pop i32) ;; pop is within a try
+ )
+ (catch_all
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ "catch's body (e-i32)'s pop's location is not valid"
+)
+
+(assert_invalid
+ (module
+ (tag $e-i32 (param i32))
+ (func $f0
+ (try
+ (do)
+ (catch $e-i32
+ (throw $e-i32
+ (if (result i32)
+ (i32.const 0)
+ (pop i32) ;; pop is within an if true body
+ (i32.const 3)
+ )
+ )
+ )
+ )
+ )
+ )
+ "catch's body (e-i32)'s pop's location is not valid"
+)