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: async func(s: string) -> string;
42  export foo: async 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  inc-backpressure: func();
62  dec-backpressure: func();
63}
64
65interface transmit {
66  variant control {
67    read-stream(string),
68    read-stream-zero,
69    read-future(string),
70    write-stream(string),
71    write-stream-zero,
72    write-future(string),
73  }
74
75  exchange: async func(control: stream<control>,
76                 caller-stream: stream<string>,
77                 caller-future1: future<string>,
78                 caller-future2: future<string>) -> tuple<stream<string>, future<string>, future<string>>;
79}
80
81interface post-return {
82  foo: async func(s: string) -> string;
83  get-post-return-value: func() -> string;
84}
85
86interface borrowing-types {
87  resource x {
88    constructor();
89    foo: func();
90  }
91}
92
93interface borrowing {
94  use borrowing-types.{x};
95
96  foo: async func(x: borrow<x>, misbehave: bool);
97}
98
99interface run-bool {
100  run: async func(v: bool);
101}
102
103interface run-result {
104  run-fail: async func() -> result<_, error-context>;
105  run-pass: async func() -> result<_, error-context>;
106}
107
108interface run-stream {
109  produce-then-error: func(times: u32) -> stream;
110}
111
112interface run-future {
113  produce-then-error: func() -> future;
114}
115
116interface unit-stream {
117  run: async func(count: u32) -> stream;
118}
119
120interface resource-stream {
121  resource x {
122    foo: func();
123  }
124
125  foo: func(count: u32) -> stream<x>;
126}
127
128interface closed {
129  read-stream: async func(rx: stream<u8>, expected: list<u8>);
130  read-future: async func(rx: future<u8>, expected: u8, rx-ignore: future<u8>);
131  read-future-post-return: async func(rx: future<u8>, expected: u8, rx-ignore: future<u8>);
132}
133
134interface sleep {
135  sleep-millis: async func(time-in-millis: u64);
136}
137
138interface sleep-with-options {
139  use cancel.{mode};
140
141  variant on-cancel {
142    task-return,
143    task-cancel
144  }
145
146  sleep-millis: async func(time-in-millis: u64, on-cancel: on-cancel, on-cancel-delay-millis: u64, synchronous-delay: bool, mode: mode);
147}
148
149interface cancel {
150  variant mode {
151    normal,
152    trap-cancel-guest-after-start-cancelled,
153    trap-cancel-guest-after-return-cancelled,
154    trap-cancel-guest-after-return,
155    trap-cancel-host-after-return-cancelled,
156    trap-cancel-host-after-return,
157    leak-task-after-cancel,
158  }
159
160  run: func(mode: mode, cancel-delay-millis: u64);
161}
162
163interface intertask {
164  foo: func(fut: future);
165}
166
167interface readiness {
168  start: async func(s: stream<u8>, expected: list<u8>) -> tuple<stream<u8>, list<u8>>;
169}
170
171interface synchronous-transmit {
172  start: async func(s: stream<u8>, s-expected: list<u8>, f: future<u8>, f-expected: u8) -> tuple<stream<u8>, list<u8>, future<u8>, u8>;
173}
174
175interface sleep-post-return {
176  run: async func(sleep-time-millis: u64);
177}
178
179interface closed-stream {
180  get: func() -> stream<u8>;
181}
182
183world yield-caller {
184  import continue;
185  import ready;
186  import run;
187  export run;
188}
189
190world yield-callee {
191  import continue;
192  export run;
193}
194
195world yield-host {
196  import continue;
197  import ready;
198  export run;
199}
200
201world poll {
202  import ready;
203  export run;
204}
205
206world backpressure-caller {
207  import backpressure;
208  import run;
209  export run;
210}
211
212world backpressure-callee {
213  export backpressure;
214  export run;
215}
216
217world transmit-caller {
218  import transmit;
219  export run;
220}
221
222world transmit-callee {
223  export transmit;
224}
225
226world post-return-caller {
227  import post-return;
228  export run;
229}
230
231world post-return-callee {
232  export post-return;
233}
234
235world borrowing-caller {
236  import borrowing;
237  export run-bool;
238}
239
240world borrowing-callee {
241  export borrowing;
242  export run-bool;
243}
244
245world borrowing-host {
246  import borrowing-types;
247  export run-bool;
248}
249
250world error-context-usage {
251  export run;
252}
253
254world error-context-callee {
255  export run-result;
256  export run;
257}
258
259world error-context-caller {
260  import run-result;
261  export run;
262}
263
264world error-context-stream-callee {
265  export run-stream;
266  export run;
267}
268
269world error-context-stream-caller {
270  import run-stream;
271  export run;
272}
273
274world error-context-future-callee {
275  export run-future;
276  export run;
277}
278
279world error-context-future-caller {
280  import run-future;
281  export run;
282}
283
284world unit-stream-caller {
285  import unit-stream;
286  export run;
287}
288
289world unit-stream-callee {
290  export unit-stream;
291}
292
293world read-resource-stream {
294  import resource-stream;
295  export run;
296}
297
298world closed-streams {
299  export closed;
300}
301
302world sleep-host {
303  import sleep;
304}
305
306world cancel-caller {
307  import backpressure;
308  import sleep;
309  import sleep-with-options;
310  export cancel;
311}
312
313world cancel-callee {
314  import sleep;
315  export backpressure;
316  export sleep;
317  export sleep-with-options;
318}
319
320world cancel-host {
321  export cancel;
322}
323
324world intertask-communication {
325  import intertask;
326  export run;
327}
328
329world readiness-guest {
330  export readiness;
331}
332
333world synchronous-transmit-guest {
334  export synchronous-transmit;
335}
336
337world sleep-post-return-callee {
338  import sleep;
339  export sleep-post-return;
340}
341
342world sleep-post-return-caller {
343  import sleep;
344  import sleep-post-return;
345  export sleep-post-return;
346}
347
348world closed-stream-guest {
349  export closed-stream;
350}
351