Debian Codegraph @

tests/cli/component-model/fixed-size-list.wast

raw
1 ;; RUN: wast % --assert default --snapshot tests/snapshots -f cm-fixed-size-list
2
3 (component
4 (core module $m
5 (memory (export "memory") 1)
6 (func (export "ret-list") (result i32) unreachable)
7 )
8 (core instance $i (instantiate $m))
9
10 (func (export "ret-list") (result (list u32 4))
11 (canon lift (core func $i "ret-list") (memory $i "memory"))
12 )
13 )
14
15 (component
16 (core module $m
17 (func (export "param-list") (param i32 i32 i32 i32) unreachable)
18 )
19 (core instance $i (instantiate $m))
20
21 (func (export "param-list") (param "l" (list u32 4))
22 (canon lift (core func $i "param-list"))
23 )
24 )
25
26 (assert_invalid
27 (component
28 (core module $m
29 (memory (export "memory") 1)
30 (func (export "ret-list") (result i32) unreachable)
31 )
32 (core instance $i (instantiate $m))
33
34 (func (export "ret-list") (result (list u32 0))
35 (canon lift (core func $i "ret-list") (memory $i "memory"))
36 )
37 )
38 "Fixed size lists must have more than zero elements (at offset 0x54)"
39 )
40
41 (assert_malformed
42 (component quote
43 "(core module $m"
44 "(memory (export \"memory\") 1)"
45 "(func (export \"ret-list\") (result i32) unreachable)"
46 ")"
47 "(core instance $i (instantiate $m))"
48
49 "(func (export \"ret-list\") (result (list u32 10000000000))"
50 "(canon lift (core func $i \"ret-list\") (memory $i \"memory\"))"
51 ")"
52 )
53 "invalid u32 number: constant out of range"
54 )
55
56 (assert_invalid
57 (component
58 (import "y" (component $c
59 (type $t (list s32 10))
60 (import "x" (type (eq $t)))
61 ))
62
63 (type $x (list u32 9))
64 (instance (instantiate $c (with "x" (type $x))))
65 )
66 "type mismatch for import `x`")
67
68
69 (assert_invalid
70 (component
71 (import "y" (component $c
72 (type $t (list s32 10))
73 (import "x" (type (eq $t)))
74 ))
75
76 (type $x (list u32))
77 (instance (instantiate $c (with "x" (type $x))))
78 )
79 "type mismatch for import `x`")