summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAsumu Takikawa <asumu@igalia.com>2021-06-29 17:34:51 -0700
committerGitHub <noreply@github.com>2021-06-29 17:34:51 -0700
commit16ab43493237c8b82ccb411618f1679a9a321148 (patch)
tree5f3abbbc341834e2453e9ad17dcd7f80a87ee422 /test
parent29323f09c63c48aef029ff308c39e1c1dc11d6c4 (diff)
downloadwabt-16ab43493237c8b82ccb411618f1679a9a321148.tar.gz
wabt-16ab43493237c8b82ccb411618f1679a9a321148.tar.bz2
wabt-16ab43493237c8b82ccb411618f1679a9a321148.zip
Allow plain `try` with no `catch` or `delegate` (#1676)
Matches recent changes in the exception handling spec that allowed this case to reduce special cases in the syntax: https://github.com/WebAssembly/exception-handling/pull/157
Diffstat (limited to 'test')
-rw-r--r--test/dump/try.txt54
-rw-r--r--test/parse/expr/bad-try-clause.txt10
-rw-r--r--test/parse/expr/bad-try-no-catch.txt14
-rw-r--r--test/parse/expr/try.txt6
-rw-r--r--test/roundtrip/fold-try.txt8
5 files changed, 56 insertions, 36 deletions
diff --git a/test/dump/try.txt b/test/dump/try.txt
index 672dc2a9..33ec7c3d 100644
--- a/test/dump/try.txt
+++ b/test/dump/try.txt
@@ -3,6 +3,9 @@
(module
(tag $e (param i32))
(func
+ try
+ nop
+ end
try $try1 (result i32)
nop
i32.const 7
@@ -55,22 +58,26 @@
0000021: 00 ; func body size (guess)
0000022: 00 ; local decl count
0000023: 06 ; try
-0000024: 7f ; i32
+0000024: 40 ; void
0000025: 01 ; nop
-0000026: 41 ; i32.const
-0000027: 07 ; i32 literal
-0000028: 07 ; catch
-0000029: 00 ; catch tag
-000002a: 1a ; drop
-000002b: 41 ; i32.const
-000002c: 08 ; i32 literal
-000002d: 0b ; end
+0000026: 0b ; end
+0000027: 06 ; try
+0000028: 7f ; i32
+0000029: 01 ; nop
+000002a: 41 ; i32.const
+000002b: 07 ; i32 literal
+000002c: 07 ; catch
+000002d: 00 ; catch tag
000002e: 1a ; drop
-000002f: 0b ; end
-0000021: 0e ; FIXUP func body size
-000001f: 10 ; FIXUP section size
-; move data: [1e, 30) -> [1b, 2d)
-; truncate to 45 (0x2d)
+000002f: 41 ; i32.const
+0000030: 08 ; i32 literal
+0000031: 0b ; end
+0000032: 1a ; drop
+0000033: 0b ; end
+0000021: 12 ; FIXUP func body size
+000001f: 14 ; FIXUP section size
+; move data: [1e, 34) -> [1b, 31)
+; truncate to 49 (0x31)
;;; STDERR ;;)
(;; STDOUT ;;;
@@ -79,13 +86,16 @@ try.wasm: file format wasm 0x1
Code Disassembly:
00001f func[0]:
- 000020: 06 7f | try i32
+ 000020: 06 40 | try
000022: 01 | nop
- 000023: 41 07 | i32.const 7
- 000025: 07 00 | catch 0
- 000027: 1a | drop
- 000028: 41 08 | i32.const 8
- 00002a: 0b | end
- 00002b: 1a | drop
- 00002c: 0b | end
+ 000023: 0b | end
+ 000024: 06 7f | try i32
+ 000026: 01 | nop
+ 000027: 41 07 | i32.const 7
+ 000029: 07 00 | catch 0
+ 00002b: 1a | drop
+ 00002c: 41 08 | i32.const 8
+ 00002e: 0b | end
+ 00002f: 1a | drop
+ 000030: 0b | end
;;; STDOUT ;;)
diff --git a/test/parse/expr/bad-try-clause.txt b/test/parse/expr/bad-try-clause.txt
new file mode 100644
index 00000000..f8575c8c
--- /dev/null
+++ b/test/parse/expr/bad-try-clause.txt
@@ -0,0 +1,10 @@
+;;; TOOL: wat2wasm
+;;; ARGS: --enable-exceptions
+;;; ERROR: 1
+(module
+ (func (try (do) (foo)))
+(;; STDERR ;;;
+out/test/parse/expr/bad-try-clause.txt:5:20: error: unexpected token "foo", expected catch, catch_all or delegate.
+ (func (try (do) (foo)))
+ ^^^
+;;; STDERR ;;)
diff --git a/test/parse/expr/bad-try-no-catch.txt b/test/parse/expr/bad-try-no-catch.txt
deleted file mode 100644
index c85756fb..00000000
--- a/test/parse/expr/bad-try-no-catch.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-;;; TOOL: wat2wasm
-;;; ARGS: --enable-exceptions
-;;; ERROR: 1
-(module
- (func try nop end)
- (func (try (do nop))))
-(;; STDERR ;;;
-out/test/parse/expr/bad-try-no-catch.txt:5:17: error: unexpected token "end", expected catch, catch_all or delegate.
- (func try nop end)
- ^^^
-out/test/parse/expr/bad-try-no-catch.txt:6:22: error: unexpected token ), expected (.
- (func (try (do nop))))
- ^
-;;; STDERR ;;)
diff --git a/test/parse/expr/try.txt b/test/parse/expr/try.txt
index c10eebc2..51ed83b5 100644
--- a/test/parse/expr/try.txt
+++ b/test/parse/expr/try.txt
@@ -3,6 +3,12 @@
(module
(tag (param i32))
+ ;; no catch
+ (func
+ try
+ nop
+ end)
+
;; bare
(func
try
diff --git a/test/roundtrip/fold-try.txt b/test/roundtrip/fold-try.txt
index d33dbbe2..412e34ca 100644
--- a/test/roundtrip/fold-try.txt
+++ b/test/roundtrip/fold-try.txt
@@ -3,6 +3,10 @@
(module
(func (result i32)
try (result i32)
+ i32.const 6
+ end
+ drop
+ try (result i32)
nop
i32.const 7
catch_all
@@ -14,6 +18,10 @@
(module
(type (;0;) (func (result i32)))
(func (;0;) (type 0) (result i32)
+ (drop
+ (try (result i32) ;; label = @1
+ (do
+ (i32.const 6))))
(try (result i32) ;; label = @1
(do
(nop)