Debian Codegraph @

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

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-async,cm-async-stackful
2
3 ;; async lift; no callback
4 (component
5 (core module $m
6 (func (export "foo") (param i32) unreachable)
7 )
8 (core instance $i (instantiate $m))
9
10 (func (export "foo") (param "p1" u32) (result u32)
11 (canon lift (core func $i "foo") async)
12 )
13 )
14
15 ;; async lift; no callback; with post-return
16 (assert_invalid
17 (component
18 (core module $m
19 (func (export "foo") (param i32) unreachable)
20 (func (export "post-return-foo") unreachable)
21 )
22 (core instance $i (instantiate $m))
23
24 (func (export "foo") (param "p1" u32) (result u32)
25 (canon lift (core func $i "foo") async (post-return (func $i "post-return-foo")))
26 )
27 )
28 "cannot specify post-return function in async"
29 )
30
31 ;; async lift; with callback
32 (component
33 (core module $m
34 (func (export "callback") (param i32 i32 i32) (result i32) unreachable)
35 (func (export "foo") (param i32) (result i32) unreachable)
36 )
37 (core instance $i (instantiate $m))
38
39 (func (export "foo") (param "p1" u32) (result u32)
40 (canon lift (core func $i "foo") async (callback (func $i "callback")))
41 )
42 )
43
44 ;; async lift; with incorrectly-typed callback
45 (assert_invalid
46 (component
47 (core module $m
48 (func (export "callback") (param i32 f32 i32) (result i32) unreachable)
49 (func (export "foo") (param i32) (result i32) unreachable)
50 )
51 (core instance $i (instantiate $m))
52
53 (func (export "foo") (param "p1" u32) (result u32)
54 (canon lift (core func $i "foo") async (callback (func $i "callback")))
55 )
56 )
57 "canonical option `callback` uses a core function with an incorrect signature"
58 )
59
60 ;; async lift; with callback and post-return
61 (assert_invalid
62 (component
63 (core module $m
64 (func (export "callback") (param i32 i32 i32) (result i32) unreachable)
65 (func (export "foo") (param i32) (result i32) unreachable)
66 (func (export "post-return-foo") (param i32) unreachable)
67 )
68 (core instance $i (instantiate $m))
69
70 (func (export "foo") (param "p1" u32) (result u32)
71 (canon lift (core func $i "foo") async (callback (func $i "callback")) (post-return (func $i "post-return-foo")))
72 )
73 )
74 "cannot specify post-return function in async"
75 )
76
77 ;; async lift; with incorrectly-typed core function
78 (assert_invalid
79 (component
80 (core module $m
81 (func (export "callback") (param i32 i32 i32) (result i32) unreachable)
82 (func (export "foo") (param i32 i32) (result i32) unreachable)
83 )
84 (core instance $i (instantiate $m))
85
86 (func (export "foo") (param "p1" u32) (result u32)
87 (canon lift (core func $i "foo") async (callback (func $i "callback")))
88 )
89 )
90 "lowered parameter types `[I32]` do not match parameter types `[I32, I32]` of core function 0"
91 )
92
93 ;; async lift; with missing callback
94 (assert_invalid
95 (component
96 (core module $m
97 (func (export "foo") (param i32) (result i32) unreachable)
98 )
99 (core instance $i (instantiate $m))
100
101 (func (export "foo") (param "p1" u32) (result u32)
102 (canon lift (core func $i "foo") async (callback (func $i "callback")))
103 )
104 )
105 "core instance 0 has no export named `callback`"
106 )
107
108 ;; sync lift; with redundant callback
109 (assert_invalid
110 (component
111 (core module $m
112 (func (export "callback") (param i32 i32 i32) (result i32) unreachable)
113 (func (export "foo") (param i32) (result i32) unreachable)
114 )
115 (core instance $i (instantiate $m))
116
117 (func (export "foo") (param "p1" u32) (result u32)
118 (canon lift (core func $i "foo") (callback (func $i "callback")))
119 )
120 )
121 "cannot specify callback without async"
122 )