| 1 |
;; RUN: wast --assert default --snapshot tests/snapshots % |
| 2 |
|
| 3 |
(component $C |
| 4 |
(type $A1 bool) |
| 5 |
(type $A2 u8) |
| 6 |
(type $A3 s8) |
| 7 |
(type $A4 u16) |
| 8 |
(type $A5 s16) |
| 9 |
(type $A6 u32) |
| 10 |
(type $A7 s32) |
| 11 |
(type $A8 u64) |
| 12 |
(type $A9 s64) |
| 13 |
(type $A10a f32) |
| 14 |
(type $A11a f64) |
| 15 |
(type $A10b float32) |
| 16 |
(type $A11b float64) |
| 17 |
(type $A12 char) |
| 18 |
(type $A13 string) |
| 19 |
|
| 20 |
(type $A14b (record (field "x" (tuple char)))) |
| 21 |
(type $A14c (record (field "x" $A1))) |
| 22 |
|
| 23 |
(type $A15a (variant (case "x"))) |
| 24 |
(type $A15b (variant (case "x" $A1))) |
| 25 |
(type $A15c (variant (case $x "x") (case $y "y" string (refines $x)) (case "z" string (refines $y)))) |
| 26 |
(type $A15d (variant (case "x") (case "y" string (refines 0)) (case "z" string (refines 1)))) |
| 27 |
|
| 28 |
(type $A16a (list (tuple u8))) |
| 29 |
(type $A16b (list $A3)) |
| 30 |
|
| 31 |
(type $A17a (tuple u8)) |
| 32 |
(type $A17b (tuple $A4)) |
| 33 |
|
| 34 |
(type $A18b (flags "x")) |
| 35 |
|
| 36 |
(type $A19b (enum "x")) |
| 37 |
|
| 38 |
(type $A21a (option (tuple u32))) |
| 39 |
(type $A21b (option $A6)) |
| 40 |
|
| 41 |
(type $A22a (result)) |
| 42 |
(type $A22b (result $A7)) |
| 43 |
(type $A22c (result (error $A8))) |
| 44 |
(type $A22d (result $A9 (error $A10a))) |
| 45 |
) |
| 46 |
|
| 47 |
(assert_malformed |
| 48 |
(component quote |
| 49 |
"(type $t (variant (case $x \"x\" string (refines $x))))" |
| 50 |
) |
| 51 |
"variant case cannot refine itself" |
| 52 |
) |
| 53 |
|
| 54 |
(assert_malformed |
| 55 |
(component quote |
| 56 |
"(type $t (variant (case \"x\" (refines $y)) (case $y \"y\" string)))" |
| 57 |
) |
| 58 |
"unknown variant case" |
| 59 |
) |
| 60 |
|
| 61 |
(assert_malformed |
| 62 |
(component quote |
| 63 |
"(type $t string)" |
| 64 |
"(type $v (variant (case \"x\" $t (refines $z))))" |
| 65 |
) |
| 66 |
"unknown variant case" |
| 67 |
) |
| 68 |
|
| 69 |
|
| 70 |
(assert_invalid |
| 71 |
(component |
| 72 |
(type $t string) |
| 73 |
(type $v (variant (case "x" $t (refines 1)))) |
| 74 |
) |
| 75 |
"variant case can only refine a previously defined case" |
| 76 |
) |
| 77 |
|
| 78 |
(assert_invalid |
| 79 |
(component |
| 80 |
(type $t string) |
| 81 |
(type $v (variant (case "x" $t) (case "y" u64 (refines 2)) (case "z" string))) |
| 82 |
) |
| 83 |
"variant case can only refine a previously defined case" |
| 84 |
) |
| 85 |
|
| 86 |
(assert_malformed |
| 87 |
(component quote |
| 88 |
"(type $t string)" |
| 89 |
"(type $v (variant (case $x \"x\" $t) (case $x \"y\" $t)))" |
| 90 |
) |
| 91 |
"duplicate variant case identifier" |
| 92 |
) |
| 93 |
|
| 94 |
(assert_invalid |
| 95 |
(component |
| 96 |
(type $t (func)) |
| 97 |
(type (func (param "t" $t))) |
| 98 |
) |
| 99 |
"type index 0 is not a defined type") |
| 100 |
|
| 101 |
(assert_invalid |
| 102 |
(component |
| 103 |
(type $t (instance)) |
| 104 |
(type (func (result $t))) |
| 105 |
) |
| 106 |
"type index 0 is not a defined type") |
| 107 |
|
| 108 |
(assert_invalid |
| 109 |
(component |
| 110 |
(type $t (component)) |
| 111 |
(type (option $t)) |
| 112 |
) |
| 113 |
"type index 0 is not a defined type") |
| 114 |
|
| 115 |
(assert_invalid |
| 116 |
(component (type (option 0))) |
| 117 |
"index out of bounds") |
| 118 |
(assert_invalid |
| 119 |
(component (type (list 0))) |
| 120 |
"index out of bounds") |
| 121 |
(assert_invalid |
| 122 |
(component (type (record (field "x" 0)))) |
| 123 |
"index out of bounds") |
| 124 |
(assert_invalid |
| 125 |
(component (type (variant (case "x" 0)))) |
| 126 |
"index out of bounds") |
| 127 |
(assert_invalid |
| 128 |
(component (type (result 0 (error 1)))) |
| 129 |
"index out of bounds") |
| 130 |
(assert_invalid |
| 131 |
(component (type (tuple 0))) |
| 132 |
"index out of bounds") |
| 133 |
|
| 134 |
(assert_invalid |
| 135 |
(component (type (record (field "a-B-c-D" string) (field "A-b-C-d" u8)))) |
| 136 |
"record field name `A-b-C-d` conflicts with previous field name `a-B-c-D`") |
| 137 |
(assert_invalid |
| 138 |
(component (type (variant (case "x" s64) (case "x" s64)))) |
| 139 |
"variant case name `x` conflicts with previous case name `x`") |
| 140 |
(assert_invalid |
| 141 |
(component (type (flags "x" "y" "X"))) |
| 142 |
"flag name `X` conflicts with previous flag name `x`") |
| 143 |
(assert_invalid |
| 144 |
(component (type (enum "x" "y" "X"))) |
| 145 |
"enum tag name `X` conflicts with previous tag name `x`") |
| 146 |
|
| 147 |
(assert_invalid |
| 148 |
(component (type (record (field "" s32)))) |
| 149 |
"name cannot be empty") |
| 150 |
(assert_invalid |
| 151 |
(component (type (variant (case "" s32)))) |
| 152 |
"name cannot be empty") |
| 153 |
(assert_invalid |
| 154 |
(component (type (flags ""))) |
| 155 |
"name cannot be empty") |
| 156 |
(assert_invalid |
| 157 |
(component (type (enum ""))) |
| 158 |
"name cannot be empty") |
| 159 |
|
| 160 |
(assert_invalid |
| 161 |
(component (type (variant))) |
| 162 |
"variant type must have at least one case") |