Debian Codegraph @

tests/cli/component-model-async/streams.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-async,cm-async-builtins
2
3 ;; stream.new
4 (component
5 (core module $m
6 (import "" "stream.new" (func $stream-new (result i64)))
7 )
8 (type $stream-type (stream u8))
9 (core func $stream-new (canon stream.new $stream-type))
10 (core instance $i (instantiate $m (with "" (instance (export "stream.new" (func $stream-new))))))
11 )
12
13 ;; stream.new; incorrect type
14 (assert_invalid
15 (component
16 (core module $m
17 (import "" "stream.new" (func $stream-new (param i32) (result i32)))
18 )
19 (type $stream-type (stream u8))
20 (core func $stream-new (canon stream.new $stream-type))
21 (core instance $i (instantiate $m (with "" (instance (export "stream.new" (func $stream-new))))))
22 )
23 "type mismatch for export `stream.new` of module instantiation argument ``"
24 )
25
26 ;; stream.read
27 (component
28 (core module $libc (memory (export "memory") 1))
29 (core instance $libc (instantiate $libc))
30 (core module $m
31 (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32)))
32 )
33 (type $stream-type (stream u8))
34 (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory")))
35 (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read))))))
36 )
37
38 ;; stream.read; with realloc
39 (component
40 (core module $libc
41 (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
42 (memory (export "memory") 1)
43 )
44 (core instance $libc (instantiate $libc))
45 (core module $m
46 (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32)))
47 )
48 (type $stream-type (stream string))
49 (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory") (realloc (func $libc "realloc"))))
50 (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read))))))
51 )
52
53 ;; stream.read; incorrect type
54 (assert_invalid
55 (component
56 (core module $libc (memory (export "memory") 1))
57 (core instance $libc (instantiate $libc))
58 (core module $m
59 (import "" "stream.read" (func $stream-read (param i32) (result i32)))
60 )
61 (type $stream-type (stream u8))
62 (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory")))
63 (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read))))))
64 )
65 "type mismatch for export `stream.read` of module instantiation argument ``"
66 )
67
68 ;; stream.read; incorrect type argument
69 (assert_invalid
70 (component
71 (core module $libc (memory (export "memory") 1))
72 (core instance $libc (instantiate $libc))
73 (core module $m
74 (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32)))
75 )
76 (type $string-type string)
77 (core func $stream-read (canon stream.read $string-type async (memory $libc "memory")))
78 (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read))))))
79 )
80 "`stream.read` requires a stream type"
81 )
82
83 ;; stream.read; missing realloc
84 (assert_invalid
85 (component
86 (core module $libc (memory (export "memory") 1))
87 (core instance $libc (instantiate $libc))
88 (core module $m
89 (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32)))
90 )
91 (type $stream-type (stream string))
92 (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory")))
93 (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read))))))
94 )
95 "canonical option `realloc` is required"
96 )
97
98 ;; stream.write
99 (component
100 (core module $libc (memory (export "memory") 1))
101 (core instance $libc (instantiate $libc))
102 (core module $m
103 (import "" "stream.write" (func $stream-write (param i32 i32 i32) (result i32)))
104 )
105 (type $stream-type (stream u8))
106 (core func $stream-write (canon stream.write $stream-type async (memory $libc "memory")))
107 (core instance $i (instantiate $m (with "" (instance (export "stream.write" (func $stream-write))))))
108 )
109
110 ;; stream.write; incorrect type
111 (assert_invalid
112 (component
113 (core module $libc (memory (export "memory") 1))
114 (core instance $libc (instantiate $libc))
115 (core module $m
116 (import "" "stream.write" (func $stream-write (param i32) (result i32)))
117 )
118 (type $stream-type (stream u8))
119 (core func $stream-write (canon stream.write $stream-type async (memory $libc "memory")))
120 (core instance $i (instantiate $m (with "" (instance (export "stream.write" (func $stream-write))))))
121 )
122 "type mismatch for export `stream.write` of module instantiation argument ``"
123 )
124
125 ;; stream.cancel-read
126 (component
127 (core module $m
128 (import "" "stream.cancel-read" (func $stream-cancel-read (param i32) (result i32)))
129 )
130 (type $stream-type (stream u8))
131 (core func $stream-cancel-read (canon stream.cancel-read $stream-type async))
132 (core instance $i (instantiate $m (with "" (instance (export "stream.cancel-read" (func $stream-cancel-read))))))
133 )
134
135 ;; stream.cancel-read; incorrect type
136 (assert_invalid
137 (component
138 (core module $m
139 (import "" "stream.cancel-read" (func $stream-cancel-read (param i32 i32) (result i32)))
140 )
141 (type $stream-type (stream u8))
142 (core func $stream-cancel-read (canon stream.cancel-read $stream-type async))
143 (core instance $i (instantiate $m (with "" (instance (export "stream.cancel-read" (func $stream-cancel-read))))))
144 )
145 "type mismatch for export `stream.cancel-read` of module instantiation argument ``"
146 )
147
148 ;; stream.cancel-write
149 (component
150 (core module $m
151 (import "" "stream.cancel-write" (func $stream-cancel-write (param i32) (result i32)))
152 )
153 (type $stream-type (stream u8))
154 (core func $stream-cancel-write (canon stream.cancel-write $stream-type async))
155 (core instance $i (instantiate $m (with "" (instance (export "stream.cancel-write" (func $stream-cancel-write))))))
156 )
157
158 ;; stream.cancel-write; incorrect type
159 (assert_invalid
160 (component
161 (core module $m
162 (import "" "stream.cancel-write" (func $stream-cancel-write (param i32 i32) (result i32)))
163 )
164 (type $stream-type (stream u8))
165 (core func $stream-cancel-write (canon stream.cancel-write $stream-type async))
166 (core instance $i (instantiate $m (with "" (instance (export "stream.cancel-write" (func $stream-cancel-write))))))
167 )
168 "type mismatch for export `stream.cancel-write` of module instantiation argument ``"
169 )
170
171 ;; stream.drop-readable
172 (component
173 (core module $m
174 (import "" "stream.drop-readable" (func $stream-drop-readable (param i32)))
175 )
176 (type $stream-type (stream u8))
177 (core func $stream-drop-readable (canon stream.drop-readable $stream-type))
178 (core instance $i (instantiate $m (with "" (instance (export "stream.drop-readable" (func $stream-drop-readable))))))
179 )
180
181 ;; stream.drop-readable; incorrect type
182 (assert_invalid
183 (component
184 (core module $m
185 (import "" "stream.drop-readable" (func $stream-drop-readable (param i32) (result i32)))
186 )
187 (type $stream-type (stream u8))
188 (core func $stream-drop-readable (canon stream.drop-readable $stream-type))
189 (core instance $i (instantiate $m (with "" (instance (export "stream.drop-readable" (func $stream-drop-readable))))))
190 )
191 "type mismatch for export `stream.drop-readable` of module instantiation argument ``"
192 )
193
194 ;; stream.drop-writable
195 (component
196 (core module $m
197 (import "" "stream.drop-writable" (func $stream-drop-writable (param i32)))
198 )
199 (type $stream-type (stream u8))
200 (core func $stream-drop-writable (canon stream.drop-writable $stream-type))
201 (core instance $i (instantiate $m (with "" (instance (export "stream.drop-writable" (func $stream-drop-writable))))))
202 )
203
204 ;; stream.drop-writable; incorrect type
205 (assert_invalid
206 (component
207 (core module $m
208 (import "" "stream.drop-writable" (func $stream-drop-writable (param i32 i32) (result i32)))
209 )
210 (type $stream-type (stream u8))
211 (core func $stream-drop-writable (canon stream.drop-writable $stream-type))
212 (core instance $i (instantiate $m (with "" (instance (export "stream.drop-writable" (func $stream-drop-writable))))))
213 )
214 "type mismatch for export `stream.drop-writable` of module instantiation argument ``"
215 )