summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/parse-bad-nominal-types.wast63
-rw-r--r--test/lit/parse-nominal-types.wast67
2 files changed, 130 insertions, 0 deletions
diff --git a/test/lit/parse-bad-nominal-types.wast b/test/lit/parse-bad-nominal-types.wast
new file mode 100644
index 000000000..e73e4e51b
--- /dev/null
+++ b/test/lit/parse-bad-nominal-types.wast
@@ -0,0 +1,63 @@
+;; Test that incorrect nominal types result in the expected parse errors
+
+;; RUN: foreach %s %t not wasm-opt -all 2>&1 | filecheck %s
+
+;; CHECK: [parse exception: unknown supertype (at 2:35)]
+(module
+ (type $bad-func (func) (extends $bad))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:39)]
+(module
+ (type $bad-struct (struct) (extends $bad))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:41)]
+(module
+ (type $bad-array (array i32) (extends $bad))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:33)]
+(module
+ (type $bad-func (func_subtype $bad))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:37)]
+(module
+ (type $bad-struct (struct_subtype $bad))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:39)]
+(module
+ (type $bad-array (array_subtype i32 $bad))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:32)]
+(module
+ (type $bad-func (func_subtype any))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:36)]
+(module
+ (type $bad-struct (struct_subtype any))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:38)]
+(module
+ (type $bad-array (array_subtype i32 any))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:32)]
+(module
+ (type $bad-func (func_subtype data))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:36)]
+(module
+ (type $bad-struct (struct_subtype func))
+)
+
+;; CHECK: [parse exception: unknown supertype (at 2:38)]
+(module
+ (type $bad-array (array_subtype i32 func))
+)
diff --git a/test/lit/parse-nominal-types.wast b/test/lit/parse-nominal-types.wast
new file mode 100644
index 000000000..c3981478d
--- /dev/null
+++ b/test/lit/parse-nominal-types.wast
@@ -0,0 +1,67 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+
+;; Test that new-style nominal types are parsed correctly.
+;; TODO: Remove --nominal below once nominal types are parsed as nominal by default.
+
+;; RUN: foreach %s %t wasm-opt --nominal -all -S -o - | filecheck %s
+;; RUN: foreach %s %t wasm-opt --nominal -all --roundtrip -S -o - | filecheck %s
+
+;; void function type
+(module
+ ;; CHECK: (type $sub (func) (extends $super))
+ (type $sub (func_subtype $super))
+
+ ;; CHECK: (type $super (func))
+ (type $super (func_subtype func))
+
+ ;; CHECK: (global $g (ref null $super) (ref.null $sub))
+ (global $g (ref null $super) (ref.null $sub))
+)
+
+;; function type with params and results
+(module
+ ;; CHECK: (type $sub (func (param i32) (result i32)) (extends $super))
+ (type $sub (func_subtype (param i32) (result i32) $super))
+
+ ;; CHECK: (type $super (func (param i32) (result i32)))
+ (type $super (func_subtype (param i32) (result i32) func))
+
+ ;; CHECK: (global $g (ref null $super) (ref.null $sub))
+ (global $g (ref null $super) (ref.null $sub))
+)
+
+;; empty struct type
+(module
+ ;; CHECK: (type $sub (struct ) (extends $super))
+ (type $sub (struct_subtype $super))
+
+ ;; CHECK: (type $super (struct ))
+ (type $super (struct_subtype data))
+
+ ;; CHECK: (global $g (ref null $super) (ref.null $sub))
+ (global $g (ref null $super) (ref.null $sub))
+)
+
+;; struct type with fields
+(module
+ ;; CHECK: (type $sub (struct (field i32) (field i64)) (extends $super))
+ (type $sub (struct_subtype i32 (field i64) $super))
+
+ ;; CHECK: (type $super (struct (field i32) (field i64)))
+ (type $super (struct_subtype (field i32) i64 data))
+
+ ;; CHECK: (global $g (ref null $super) (ref.null $sub))
+ (global $g (ref null $super) (ref.null $sub))
+)
+
+;; array type
+(module
+ ;; CHECK: (type $sub (array i8) (extends $super))
+ (type $sub (array_subtype i8 $super))
+
+ ;; CHECK: (type $super (array i8))
+ (type $super (array_subtype i8 data))
+
+ ;; CHECK: (global $g (ref null $super) (ref.null $sub))
+ (global $g (ref null $super) (ref.null $sub))
+)