1package local:local;
2
3interface baz {
4  foo: async func(s: string) -> string;
5}
6
7world round-trip {
8  import baz;
9  export baz;
10}
11
12interface many {
13  record stuff {
14    a: list<s32>,
15    b: bool,
16    c: u64
17  }
18
19  foo: async func(a: string,
20            b: u32,
21            c: list<u8>,
22            d: tuple<u64, u64>,
23            e: stuff,
24            f: option<stuff>,
25            g: result<stuff>)
26    -> tuple<string,
27             u32,
28             list<u8>,
29             tuple<u64, u64>,
30             stuff,
31             option<stuff>,
32             result<stuff>>;
33}
34
35world round-trip-many {
36  import many;
37  export many;
38}
39
40world round-trip-direct {
41  import foo: func(s: string) -> string;
42  export foo: func(s: string) -> string;
43}
44
45interface ready {
46  set-ready: func(ready: bool);
47  when-ready: async func();
48}
49
50interface continue {
51  set-continue: func(continue: bool);
52  get-continue: func() -> bool;
53}
54
55interface run {
56  run: async func();
57}
58
59interface backpressure {
60  set-backpressure: func(enabled: bool);
61}
62
63interface transmit {
64  variant control {
65    read-stream(string),
66    read-stream-zero,
67    read-future(string),
68    write-stream(string),
69    write-stream-zero,
70    write-future(string),
71  }
72
73  exchange: async func(control: stream<control>,
74                 caller-stream: stream<string>,
75                 caller-future1: future<string>,
76                 caller-future2: future<string>) -> tuple<stream<string>, future<string>, future<string>>;
77}
78
79interface post-return {
80  foo: async func(s: string) -> string;
81  get-post-return-value: func() -> string;
82}
83
84interface borrowing-types {
85  resource x {
86    constructor();
87    foo: func();
88  }
89}
90
91interface borrowing {
92  use borrowing-types.{x};
93
94  foo: async func(x: borrow<x>, misbehave: bool);
95}
96
97interface run-bool {
98  run: async func(v: bool);
99}
100
101interface run-result {
102  run-fail: async func() -> result<_, error-context>;
103  run-pass: async func() -> result<_, error-context>;
104}
105
106interface run-stream {
107  produce-then-error: func(times: u32) -> stream;
108}
109
110interface run-future {
111  produce-then-error: func() -> future;
112}
113
114interface unit-stream {
115  run: async func(count: u32) -> stream;
116}
117
118interface resource-stream {
119  resource x {
120    foo: func();
121  }
122
123  foo: func(count: u32) -> stream<x>;
124}
125
126interface closed {
127  read-stream: func(rx: stream<u8>, expected: list<u8>);
128  read-future: func(rx: future<u8>, expected: u8, rx-ignore: future<u8>);
129}
130
131interface sleep {
132  sleep-millis: async func(time-in-millis: u64);
133}
134
135interface sleep-with-options {
136  use cancel.{mode};
137
138  variant on-cancel {
139    task-return,
140    task-cancel
141  }
142
143  sleep-millis: async func(time-in-millis: u64, on-cancel: on-cancel, on-cancel-delay-millis: u64, synchronous-delay: bool, mode: mode);
144}
145
146interface cancel {
147  variant mode {
148    normal,
149    trap-cancel-guest-after-start-cancelled,
150    trap-cancel-guest-after-return-cancelled,
151    trap-cancel-guest-after-return,
152    trap-cancel-host-after-return-cancelled,
153    trap-cancel-host-after-return,
154  }
155
156  run: func(mode: mode, cancel-delay-millis: u64);
157}
158
159interface intertask {
160  foo: func(fut: future);
161}
162
163world yield-caller {
164  import continue;
165  import ready;
166  import run;
167  export run;
168}
169
170world yield-callee {
171  import continue;
172  export run;
173}
174
175world yield-host {
176  import continue;
177  import ready;
178  export run;
179}
180
181world poll {
182  import ready;
183  export run;
184}
185
186world backpressure-caller {
187  import backpressure;
188  import run;
189  export run;
190}
191
192world backpressure-callee {
193  export backpressure;
194  export run;
195}
196
197world transmit-caller {
198  import transmit;
199  export run;
200}
201
202world transmit-callee {
203  export transmit;
204}
205
206world post-return-caller {
207  import post-return;
208  export run;
209}
210
211world post-return-callee {
212  export post-return;
213}
214
215world borrowing-caller {
216  import borrowing;
217  export run-bool;
218}
219
220world borrowing-callee {
221  export borrowing;
222  export run-bool;
223}
224
225world borrowing-host {
226  import borrowing-types;
227  export run-bool;
228}
229
230world error-context-usage {
231  export run;
232}
233
234world error-context-callee {
235  export run-result;
236  export run;
237}
238
239world error-context-caller {
240  import run-result;
241  export run;
242}
243
244world error-context-stream-callee {
245  export run-stream;
246  export run;
247}
248
249world error-context-stream-caller {
250  import run-stream;
251  export run;
252}
253
254world error-context-future-callee {
255  export run-future;
256  export run;
257}
258
259world error-context-future-caller {
260  import run-future;
261  export run;
262}
263
264world unit-stream-caller {
265  import unit-stream;
266  export run;
267}
268
269world unit-stream-callee {
270  export unit-stream;
271}
272
273world read-resource-stream {
274  import resource-stream;
275  export run;
276}
277
278world closed-streams {
279  export closed;
280}
281
282world sleep-host {
283  import sleep;
284}
285
286world cancel-caller {
287  import backpressure;
288  import sleep;
289  import sleep-with-options;
290  export cancel;
291}
292
293world cancel-callee {
294  import sleep;
295  export backpressure;
296  export sleep;
297  export sleep-with-options;
298}
299
300world cancel-host {
301  export cancel;
302}
303
304world intertask-communication {
305  import intertask;
306  export run;
307}
308