Debian Codegraph @

tests/cli/missing-features/component-model/async.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots % -f=-cm-async
2
3 ;; async lift
4 (assert_invalid
5 (component
6 (core module $m
7 (func (export "foo") (param i32) (result i32) unreachable)
8 )
9 (core instance $i (instantiate $m))
10
11 (func (export "foo") (param "p1" u32) (result u32)
12 (canon lift (core func $i "foo") async)
13 )
14 )
15 "canonical option `async` requires the component model async feature"
16 )
17
18 ;; async lower
19 (assert_invalid
20 (component
21 (import "foo" (func $foo (param "p1" u32) (result u32)))
22 (core module $libc (memory (export "memory") 1))
23 (core instance $libc (instantiate $libc))
24 (core func $foo (canon lower (func $foo) async (memory $libc "memory")))
25 (core module $m
26 (func (import "" "foo") (param i32 i32) (result i32))
27 )
28 (core instance $i (instantiate $m (with "" (instance (export "foo" (func $foo))))))
29 )
30 "canonical option `async` requires the component model async feature"
31 )
32
33 ;; backpressure.set
34 (assert_invalid
35 (component
36 (core module $m
37 (import "" "backpressure.set" (func $backpressure-set (param i32)))
38 )
39 (core func $backpressure.set (canon backpressure.set))
40 (core instance $i (instantiate $m (with "" (instance (export "backpressure.set" (func $backpressure.set))))))
41 )
42 "`backpressure.set` requires the component model async feature"
43 )
44
45 ;; backpressure.inc
46 (assert_invalid
47 (component
48 (core module $m
49 (import "" "backpressure.inc" (func $backpressure-inc (param i32)))
50 )
51 (core func $backpressure.inc (canon backpressure.inc))
52 (core instance $i (instantiate $m (with "" (instance (export "backpressure.inc" (func $backpressure.inc))))))
53 )
54 "`backpressure.inc` requires the component model async feature"
55 )
56
57 ;; backpressure.dec
58 (assert_invalid
59 (component
60 (core module $m
61 (import "" "backpressure.dec" (func $backpressure-dec (param i32)))
62 )
63 (core func $backpressure.dec (canon backpressure.dec))
64 (core instance $i (instantiate $m (with "" (instance (export "backpressure.dec" (func $backpressure.dec))))))
65 )
66 "`backpressure.dec` requires the component model async feature"
67 )
68
69 ;; task.return
70 (assert_invalid
71 (component
72 (core module $m
73 (import "" "task.return" (func $task-return (param i32)))
74 )
75 (core func $task-return (canon task.return (result u32)))
76 (core instance $i (instantiate $m (with "" (instance (export "task.return" (func $task-return))))))
77 )
78 "`task.return` requires the component model async feature"
79 )
80
81 ;; task.cancel
82 (assert_invalid
83 (component
84 (core module $m
85 (import "" "task.cancel" (func $task-cancel))
86 )
87 (core func $task-cancel (canon task.cancel))
88 (core instance $i (instantiate $m (with "" (instance (export "task.cancel" (func $task-cancel))))))
89 )
90 "`task.cancel` requires the component model async feature"
91 )
92
93 ;; waitable-set.new
94 (assert_invalid
95 (component (core func (canon waitable-set.new)))
96 "`waitable-set.new` requires the component model async feature"
97 )
98
99 ;; waitable-set.wait
100 (assert_invalid
101 (component
102 (core module $libc (memory (export "memory") 1))
103 (core instance $libc (instantiate $libc))
104 (core module $m
105 (import "" "waitable-set.wait" (func $waitable-set-wait (param i32) (result i32)))
106 )
107 (core func $waitable-set-wait (canon waitable-set.wait (memory $libc "memory")))
108 (core instance $i (instantiate $m (with "" (instance (export "waitable-set.wait" (func $waitable-set-wait))))))
109 )
110 "`waitable-set.wait` requires the component model async feature"
111 )
112
113 ;; waitable-set.poll
114 (assert_invalid
115 (component
116 (core module $libc (memory (export "memory") 1))
117 (core instance $libc (instantiate $libc))
118 (core module $m
119 (import "" "waitable-set.poll" (func $waitable-set-poll (param i32) (result i32)))
120 )
121 (core func $waitable-set-poll (canon waitable-set.poll (memory $libc "memory")))
122 (core instance $i (instantiate $m (with "" (instance (export "waitable-set.poll" (func $waitable-set-poll))))))
123 )
124 "`waitable-set.poll` requires the component model async feature"
125 )
126
127 ;; waitable-set.drop
128 (assert_invalid
129 (component (core func (canon waitable-set.drop)))
130 "`waitable-set.drop` requires the component model async feature"
131 )
132
133 ;; waitable.join
134 (assert_invalid
135 (component (core func (canon waitable.join)))
136 "`waitable.join` requires the component model async feature"
137 )
138
139 ;; subtask.drop
140 (assert_invalid
141 (component
142 (core module $m
143 (import "" "subtask.drop" (func $subtask-drop (param i32)))
144 )
145 (core func $subtask-drop (canon subtask.drop))
146 (core instance $i (instantiate $m (with "" (instance (export "subtask.drop" (func $subtask-drop))))))
147 )
148 "`subtask.drop` requires the component model async feature"
149 )
150
151 ;; subtask.cancel
152 (assert_invalid
153 (component
154 (core module $m
155 (import "" "subtask.cancel" (func $subtask-cancel (param i32)))
156 )
157 (core func $subtask-cancel (canon subtask.cancel))
158 (core instance $i (instantiate $m (with "" (instance (export "subtask.cancel" (func $subtask-cancel))))))
159 )
160 "`subtask.cancel` requires the component model async feature"
161 )
162
163 ;; stream.new
164 (assert_invalid
165 (component
166 (core module $m
167 (import "" "stream.new" (func $stream-new (result i32)))
168 )
169 (type $stream-type (stream u8))
170 (core func $stream-new (canon stream.new $stream-type))
171 (core instance $i (instantiate $m (with "" (instance (export "stream.new" (func $stream-new))))))
172 )
173 "requires the component model async feature"
174 )
175
176 ;; stream.read
177 (assert_invalid
178 (component
179 (core module $libc (memory (export "memory") 1))
180 (core instance $libc (instantiate $libc))
181 (core module $m
182 (import "" "stream.read" (func $stream-read (param i32 i32 i32) (result i32)))
183 )
184 (type $stream-type (stream u8))
185 (core func $stream-read (canon stream.read $stream-type async (memory $libc "memory")))
186 (core instance $i (instantiate $m (with "" (instance (export "stream.read" (func $stream-read))))))
187 )
188 "requires the component model async feature"
189 )
190
191 ;; stream.write
192 (assert_invalid
193 (component
194 (core module $libc (memory (export "memory") 1))
195 (core instance $libc (instantiate $libc))
196 (core module $m
197 (import "" "stream.write" (func $stream-write (param i32 i32 i32) (result i32)))
198 )
199 (type $stream-type (stream u8))
200 (core func $stream-write (canon stream.write $stream-type async (memory $libc "memory")))
201 (core instance $i (instantiate $m (with "" (instance (export "stream.write" (func $stream-write))))))
202 )
203 "requires the component model async feature"
204 )
205
206 ;; stream.cancel-read
207 (assert_invalid
208 (component
209 (core module $m
210 (import "" "stream.cancel-read" (func $stream-cancel-read (param i32) (result i32)))
211 )
212 (type $stream-type (stream u8))
213 (core func $stream-cancel-read (canon stream.cancel-read $stream-type async))
214 (core instance $i (instantiate $m (with "" (instance (export "stream.cancel-read" (func $stream-cancel-read))))))
215 )
216 "requires the component model async feature"
217 )
218
219 ;; stream.cancel-write
220 (assert_invalid
221 (component
222 (core module $m
223 (import "" "stream.cancel-write" (func $stream-cancel-write (param i32) (result i32)))
224 )
225 (type $stream-type (stream u8))
226 (core func $stream-cancel-write (canon stream.cancel-write $stream-type async))
227 (core instance $i (instantiate $m (with "" (instance (export "stream.cancel-write" (func $stream-cancel-write))))))
228 )
229 "requires the component model async feature"
230 )
231
232 ;; stream.drop-readable
233 (assert_invalid
234 (component
235 (core module $m
236 (import "" "stream.drop-readable" (func $stream-drop-readable (param i32)))
237 )
238 (type $stream-type (stream u8))
239 (core func $stream-drop-readable (canon stream.drop-readable $stream-type))
240 (core instance $i (instantiate $m (with "" (instance (export "stream.drop-readable" (func $stream-drop-readable))))))
241 )
242 "requires the component model async feature"
243 )
244
245 ;; stream.drop-writable
246 (assert_invalid
247 (component
248 (core module $m
249 (import "" "stream.drop-writable" (func $stream-drop-writable (param i32 i32)))
250 )
251 (type $stream-type (stream u8))
252 (core func $stream-drop-writable (canon stream.drop-writable $stream-type))
253 (core instance $i (instantiate $m (with "" (instance (export "stream.drop-writable" (func $stream-drop-writable))))))
254 )
255 "requires the component model async feature"
256 )
257
258 ;; future.new
259 (assert_invalid
260 (component
261 (core module $m
262 (import "" "future.new" (func $future-new (result i32)))
263 )
264 (type $future-type (future u8))
265 (core func $future-new (canon future.new $future-type))
266 (core instance $i (instantiate $m (with "" (instance (export "future.new" (func $future-new))))))
267 )
268 "requires the component model async feature"
269 )
270
271 ;; future.read
272 (assert_invalid
273 (component
274 (core module $libc (memory (export "memory") 1))
275 (core instance $libc (instantiate $libc))
276 (core module $m
277 (import "" "future.read" (func $future-read (param i32 i32) (result i32)))
278 )
279 (type $future-type (future u8))
280 (core func $future-read (canon future.read $future-type async (memory $libc "memory")))
281 (core instance $i (instantiate $m (with "" (instance (export "future.read" (func $future-read))))))
282 )
283 "requires the component model async feature"
284 )
285
286 ;; future.write
287 (assert_invalid
288 (component
289 (core module $libc (memory (export "memory") 1))
290 (core instance $libc (instantiate $libc))
291 (core module $m
292 (import "" "future.write" (func $future-write (param i32 i32) (result i32)))
293 )
294 (type $future-type (future u8))
295 (core func $future-write (canon future.write $future-type async (memory $libc "memory")))
296 (core instance $i (instantiate $m (with "" (instance (export "future.write" (func $future-write))))))
297 )
298 "requires the component model async feature"
299 )
300
301 ;; future.cancel-read
302 (assert_invalid
303 (component
304 (core module $m
305 (import "" "future.cancel-read" (func $future-cancel-read (param i32) (result i32)))
306 )
307 (type $future-type (future u8))
308 (core func $future-cancel-read (canon future.cancel-read $future-type async))
309 (core instance $i (instantiate $m (with "" (instance (export "future.cancel-read" (func $future-cancel-read))))))
310 )
311 "requires the component model async feature"
312 )
313
314 ;; future.cancel-write
315 (assert_invalid
316 (component
317 (core module $m
318 (import "" "future.cancel-write" (func $future-cancel-write (param i32) (result i32)))
319 )
320 (type $future-type (future u8))
321 (core func $future-cancel-write (canon future.cancel-write $future-type async))
322 (core instance $i (instantiate $m (with "" (instance (export "future.cancel-write" (func $future-cancel-write))))))
323 )
324 "requires the component model async feature"
325 )
326
327 ;; future.drop-readable
328 (assert_invalid
329 (component
330 (core module $m
331 (import "" "future.drop-readable" (func $future-drop-readable (param i32)))
332 )
333 (type $future-type (future u8))
334 (core func $future-drop-readable (canon future.drop-readable $future-type))
335 (core instance $i (instantiate $m (with "" (instance (export "future.drop-readable" (func $future-drop-readable))))))
336 )
337 "requires the component model async feature"
338 )
339
340 ;; future.drop-writable
341 (assert_invalid
342 (component
343 (core module $m
344 (import "" "future.drop-writable" (func $future-drop-writable (param i32 i32)))
345 )
346 (type $future-type (future u8))
347 (core func $future-drop-writable (canon future.drop-writable $future-type))
348 (core instance $i (instantiate $m (with "" (instance (export "future.drop-writable" (func $future-drop-writable))))))
349 )
350 "requires the component model async feature"
351 )
352
353 ;; various types
354 (assert_invalid
355 (component (type (future)))
356 "requires the component model async feature"
357 )
358 (assert_invalid
359 (component (type (stream)))
360 "requires the component model async feature"
361 )
362 (assert_invalid
363 (component
364 (type $t (resource (rep i32)))
365 (core func $f (canon resource.drop $t async))
366 )
367 "requires the component model async builtins feature"
368 )
369
370 (assert_invalid
371 (component (import "[async]f" (func)))
372 "require the component model async feature"
373 )
374
375 (assert_invalid
376 (component (import "[async method]a.b" (func)))
377 "require the component model async feature"
378 )
379
380 (assert_invalid
381 (component (import "[async static]a.b" (func)))
382 "require the component model async feature"
383 )