| 1 |
;; RUN: wast --assert default --snapshot tests/snapshots % |
| 2 |
|
| 3 |
(assert_invalid |
| 4 |
(component |
| 5 |
(type $t (instance)) |
| 6 |
(import "a" (func (type $t))) |
| 7 |
) |
| 8 |
"type index 0 is not a function type") |
| 9 |
|
| 10 |
(assert_invalid |
| 11 |
(component |
| 12 |
(core type $t (func)) |
| 13 |
(import "a" (core module (type $t))) |
| 14 |
) |
| 15 |
"core type index 0 is not a module type") |
| 16 |
|
| 17 |
(assert_invalid |
| 18 |
(component |
| 19 |
(type $t (func)) |
| 20 |
(import "a" (instance (type $t))) |
| 21 |
) |
| 22 |
"type index 0 is not an instance type") |
| 23 |
|
| 24 |
(assert_invalid |
| 25 |
(component |
| 26 |
(type $t (func)) |
| 27 |
(type (component |
| 28 |
(import "a" (instance (type $t))) |
| 29 |
)) |
| 30 |
) |
| 31 |
"type index 0 is not an instance type") |
| 32 |
|
| 33 |
(assert_invalid |
| 34 |
(component |
| 35 |
(core type $t (func)) |
| 36 |
(type (component |
| 37 |
(import "a" (core module (type $t))) |
| 38 |
)) |
| 39 |
) |
| 40 |
"core type index 0 is not a module type") |
| 41 |
|
| 42 |
(assert_invalid |
| 43 |
(component |
| 44 |
(type $t (instance)) |
| 45 |
(type (component |
| 46 |
(import "a" (func (type $t))) |
| 47 |
)) |
| 48 |
) |
| 49 |
"type index 0 is not a function type") |
| 50 |
|
| 51 |
(assert_invalid |
| 52 |
(component |
| 53 |
(export "a" (core module 0)) |
| 54 |
) |
| 55 |
"module index out of bounds") |
| 56 |
|
| 57 |
(assert_invalid |
| 58 |
(component |
| 59 |
(export "a" (instance 0)) |
| 60 |
) |
| 61 |
"instance index out of bounds") |
| 62 |
|
| 63 |
(assert_invalid |
| 64 |
(component |
| 65 |
(core type (module |
| 66 |
(export "a" (func (type 0))) |
| 67 |
)) |
| 68 |
) |
| 69 |
"type index out of bounds") |
| 70 |
|
| 71 |
(assert_invalid |
| 72 |
(component |
| 73 |
(core type (module |
| 74 |
(export "a" (func)) |
| 75 |
(export "a" (func)) |
| 76 |
)) |
| 77 |
) |
| 78 |
"export name `a` already defined") |
| 79 |
|
| 80 |
(assert_invalid |
| 81 |
(component |
| 82 |
(core type (module |
| 83 |
(import "" "" (func)) |
| 84 |
(import "" "" (func)) |
| 85 |
)) |
| 86 |
) |
| 87 |
"duplicate import name") |
| 88 |
|
| 89 |
(assert_invalid |
| 90 |
(component |
| 91 |
(core type (module |
| 92 |
(import "" "" (memory 70000)) |
| 93 |
)) |
| 94 |
) |
| 95 |
"memory size must be at most") |
| 96 |
|
| 97 |
(assert_invalid |
| 98 |
(component |
| 99 |
(type (component |
| 100 |
(export "a" (func (type 0))) |
| 101 |
)) |
| 102 |
) |
| 103 |
"type index out of bounds") |
| 104 |
|
| 105 |
(assert_invalid |
| 106 |
(component |
| 107 |
(type (component |
| 108 |
(export "a" (func)) |
| 109 |
(export "A" (func)) |
| 110 |
)) |
| 111 |
) |
| 112 |
"export name `A` conflicts with previous name `a`") |
| 113 |
|
| 114 |
(assert_invalid |
| 115 |
(component |
| 116 |
(type (component |
| 117 |
(import "A" (func)) |
| 118 |
(import "a" (func)) |
| 119 |
)) |
| 120 |
) |
| 121 |
"import name `a` conflicts with previous name `A`") |
| 122 |
|
| 123 |
(assert_malformed |
| 124 |
(component quote |
| 125 |
"(component $c (core type $t (module (alias outer $c $t (type)))))" |
| 126 |
) |
| 127 |
"unknown core type") |
| 128 |
|
| 129 |
(assert_invalid |
| 130 |
(component |
| 131 |
(core type (module |
| 132 |
(alias outer 1 0 (type)) |
| 133 |
)) |
| 134 |
) |
| 135 |
"type index out of bounds") |
| 136 |
|
| 137 |
(component $c |
| 138 |
(core type $f (func)) |
| 139 |
(core type $t (module |
| 140 |
(alias outer $c $f (type)) |
| 141 |
)) |
| 142 |
) |
| 143 |
|
| 144 |
(assert_malformed |
| 145 |
(component quote |
| 146 |
"(component $c (type $t (component (alias outer $c $t (type)))))" |
| 147 |
) |
| 148 |
"unknown type") |
| 149 |
|
| 150 |
(assert_invalid |
| 151 |
(component |
| 152 |
(type (component |
| 153 |
(alias outer 1 0 (type)) |
| 154 |
)) |
| 155 |
) |
| 156 |
"type index out of bounds") |
| 157 |
|
| 158 |
(assert_invalid |
| 159 |
(component $c |
| 160 |
(type $f (func)) |
| 161 |
(type $t (component |
| 162 |
(alias outer 100 0 (type)) |
| 163 |
)) |
| 164 |
) |
| 165 |
"invalid outer alias count of 100") |
| 166 |
|
| 167 |
(assert_invalid |
| 168 |
(component $c |
| 169 |
(type $f (func)) |
| 170 |
(type $t (component |
| 171 |
(core type (module |
| 172 |
(export "" (func)) |
| 173 |
(export "" (func)) |
| 174 |
)) |
| 175 |
)) |
| 176 |
) |
| 177 |
"name `` already defined") |
| 178 |
|
| 179 |
(assert_invalid |
| 180 |
(component |
| 181 |
(type (instance |
| 182 |
(export "" (func (type 0))) |
| 183 |
)) |
| 184 |
) |
| 185 |
"type index out of bounds") |
| 186 |
|
| 187 |
(assert_invalid |
| 188 |
(component |
| 189 |
(type (instance |
| 190 |
(export "foo-BAR-baz" (func)) |
| 191 |
(export "FOO-bar-BAZ" (func)) |
| 192 |
)) |
| 193 |
) |
| 194 |
"export name `FOO-bar-BAZ` conflicts with previous name `foo-BAR-baz`") |
| 195 |
|
| 196 |
(assert_malformed |
| 197 |
(component quote |
| 198 |
"(component $c (type $t (instance (alias outer $c $t (type)))))" |
| 199 |
) |
| 200 |
"unknown type") |
| 201 |
|
| 202 |
(assert_invalid |
| 203 |
(component |
| 204 |
(type (instance |
| 205 |
(alias outer 1 0 (type)) |
| 206 |
)) |
| 207 |
) |
| 208 |
"type index out of bounds") |
| 209 |
|
| 210 |
(assert_invalid |
| 211 |
(component $c |
| 212 |
(type $f (func)) |
| 213 |
(type $t (instance |
| 214 |
(alias outer 100 0 (type)) |
| 215 |
)) |
| 216 |
) |
| 217 |
"invalid outer alias count of 100") |
| 218 |
|
| 219 |
(assert_invalid |
| 220 |
(component $c |
| 221 |
(type $f (func)) |
| 222 |
(type $t (instance |
| 223 |
(core type (module |
| 224 |
(export "" (func)) |
| 225 |
(export "" (func)) |
| 226 |
)) |
| 227 |
)) |
| 228 |
) |
| 229 |
"name `` already defined") |
| 230 |
|
| 231 |
(assert_invalid |
| 232 |
(component $c |
| 233 |
(type $f (func (param "" string))) |
| 234 |
) |
| 235 |
"function parameter name cannot be empty") |
| 236 |
|
| 237 |
(component |
| 238 |
(type $t (func (result (tuple (list u8) u32)))) |
| 239 |
) |
| 240 |
|
| 241 |
(component $C |
| 242 |
(core type $t (func)) |
| 243 |
(core type (module |
| 244 |
(alias outer $C $t (type $a)) |
| 245 |
(import "" "" (func (type $a))) |
| 246 |
)) |
| 247 |
) |
| 248 |
|
| 249 |
(component $C |
| 250 |
(component $C2 |
| 251 |
(core type $t (func)) |
| 252 |
(core type (module |
| 253 |
(alias outer $C2 $t (type $a)) |
| 254 |
(import "" "" (func (type $a))) |
| 255 |
)) |
| 256 |
) |
| 257 |
) |
| 258 |
|
| 259 |
(component $C |
| 260 |
(core type $t (func)) |
| 261 |
(component $C2 |
| 262 |
(core type (module |
| 263 |
(alias outer $C $t (type $a)) |
| 264 |
(import "" "" (func (type $a))) |
| 265 |
)) |
| 266 |
) |
| 267 |
) |
| 268 |
|
| 269 |
(component |
| 270 |
(type (instance |
| 271 |
(type string) |
| 272 |
(export "a" (type (eq 0))) |
| 273 |
)) |
| 274 |
) |
| 275 |
|
| 276 |
(component |
| 277 |
(type (component |
| 278 |
(type string) |
| 279 |
(import "a" (type (eq 0))) |
| 280 |
(export "b" (type (eq 0))) |
| 281 |
)) |
| 282 |
) |
| 283 |
|
| 284 |
(assert_invalid |
| 285 |
(component |
| 286 |
(type (variant)) |
| 287 |
) |
| 288 |
"variant type must have at least one case") |
| 289 |
|
| 290 |
(assert_invalid |
| 291 |
(component |
| 292 |
(type (enum)) |
| 293 |
) |
| 294 |
"enum type must have at least one variant") |
| 295 |
|
| 296 |
(assert_invalid |
| 297 |
(component |
| 298 |
(type (record)) |
| 299 |
) |
| 300 |
"record type must have at least one field") |
| 301 |
|
| 302 |
(assert_invalid |
| 303 |
(component |
| 304 |
(type (flags)) |
| 305 |
) |
| 306 |
"flags must have at least one entry") |
| 307 |
|
| 308 |
(assert_invalid |
| 309 |
(component |
| 310 |
(type (tuple)) |
| 311 |
) |
| 312 |
"tuple type must have at least one type") |
| 313 |
|
| 314 |
(component $c |
| 315 |
(core type $f (func)) |
| 316 |
(component $c2 |
| 317 |
(core type $t (module |
| 318 |
(alias outer $c $f (type)) |
| 319 |
)) |
| 320 |
) |
| 321 |
) |
| 322 |
|
| 323 |
(assert_invalid |
| 324 |
(component |
| 325 |
(type (flags |
| 326 |
"f1" |
| 327 |
"f2" |
| 328 |
"f3" |
| 329 |
"f4" |
| 330 |
"f5" |
| 331 |
"f6" |
| 332 |
"f7" |
| 333 |
"f8" |
| 334 |
"f9" |
| 335 |
"f10" |
| 336 |
"f11" |
| 337 |
"f12" |
| 338 |
"f13" |
| 339 |
"f14" |
| 340 |
"f15" |
| 341 |
"f16" |
| 342 |
"f17" |
| 343 |
"f18" |
| 344 |
"f19" |
| 345 |
"f20" |
| 346 |
"f21" |
| 347 |
"f22" |
| 348 |
"f23" |
| 349 |
"f24" |
| 350 |
"f25" |
| 351 |
"f26" |
| 352 |
"f27" |
| 353 |
"f28" |
| 354 |
"f29" |
| 355 |
"f30" |
| 356 |
"f31" |
| 357 |
"f32" |
| 358 |
"f33" |
| 359 |
)) |
| 360 |
) |
| 361 |
"cannot have more than 32 flags") |
| 362 |
|
| 363 |
;; test components with non-mvp types |
| 364 |
(component |
| 365 |
;; all abstract heap types work |
| 366 |
(core type (func (param (ref any)))) |
| 367 |
(core type (func (param (ref func)))) |
| 368 |
(core type (func (param (ref extern)))) |
| 369 |
(core type (func (param (ref exn)))) |
| 370 |
(core type (func (param (ref noexn)))) |
| 371 |
(core type (func (param (ref eq)))) |
| 372 |
(core type (func (param (ref struct)))) |
| 373 |
(core type (func (param (ref array)))) |
| 374 |
(core type (func (param (ref nofunc)))) |
| 375 |
(core type (func (param (ref noextern)))) |
| 376 |
(core type (func (param (ref none)))) |
| 377 |
(core type (func (param (ref i31)))) |
| 378 |
|
| 379 |
;; some shorthands work |
| 380 |
(core type (func (param anyref))) |
| 381 |
(core type (func (param eqref))) |
| 382 |
|
| 383 |
;; simd types work |
| 384 |
(core type (func (param v128))) |
| 385 |
|
| 386 |
;; types-pointing-to-types works |
| 387 |
(core type $t (func)) |
| 388 |
(core type (func (param (ref $t)))) |
| 389 |
|
| 390 |
) |
| 391 |
|
| 392 |
(assert_invalid |
| 393 |
(component |
| 394 |
(core type $t (module)) |
| 395 |
(core type (func (param (ref $t)))) |
| 396 |
) |
| 397 |
"type index 0 is a module type") |
| 398 |
|
| 399 |
(assert_invalid |
| 400 |
(component |
| 401 |
(core type (func (param (ref 100)))) |
| 402 |
) |
| 403 |
"type index out of bounds") |