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}
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: async func(rx: stream<u8>, expected: list<u8>);
128  read-future: async func(rx: future<u8>, expected: u8, rx-ignore: future<u8>);
129  read-future-post-return: async func(rx: future<u8>, expected: u8, rx-ignore: future<u8>);
130}
131
132interface sleep {
133  sleep-millis: async func(time-in-millis: u64);
134}
135
136interface sleep-with-options {
137  use cancel.{mode};
138
139  variant on-cancel {
140    task-return,
141    task-cancel
142  }
143
144  sleep-millis: async func(time-in-millis: u64, on-cancel: on-cancel, on-cancel-delay-millis: u64, synchronous-delay: bool, mode: mode);
145}
146
147interface cancel {
148  variant mode {
149    normal,
150    trap-cancel-guest-after-start-cancelled,
151    trap-cancel-guest-after-return-cancelled,
152    trap-cancel-guest-after-return,
153    trap-cancel-host-after-return-cancelled,
154    trap-cancel-host-after-return,
155    leak-task-after-cancel,
156  }
157
158  run: func(mode: mode, cancel-delay-millis: u64);
159}
160
161interface intertask {
162  foo: func(fut: future);
163}
164
165world yield-caller {
166  import continue;
167  import ready;
168  import run;
169  export run;
170}
171
172world yield-callee {
173  import continue;
174  export run;
175}
176
177world yield-host {
178  import continue;
179  import ready;
180  export run;
181}
182
183world poll {
184  import ready;
185  export run;
186}
187
188world backpressure-caller {
189  import backpressure;
190  import run;
191  export run;
192}
193
194world backpressure-callee {
195  export backpressure;
196  export run;
197}
198
199world transmit-caller {
200  import transmit;
201  export run;
202}
203
204world transmit-callee {
205  export transmit;
206}
207
208world post-return-caller {
209  import post-return;
210  export run;
211}
212
213world post-return-callee {
214  export post-return;
215}
216
217world borrowing-caller {
218  import borrowing;
219  export run-bool;
220}
221
222world borrowing-callee {
223  export borrowing;
224  export run-bool;
225}
226
227world borrowing-host {
228  import borrowing-types;
229  export run-bool;
230}
231
232world error-context-usage {
233  export run;
234}
235
236world error-context-callee {
237  export run-result;
238  export run;
239}
240
241world error-context-caller {
242  import run-result;
243  export run;
244}
245
246world error-context-stream-callee {
247  export run-stream;
248  export run;
249}
250
251world error-context-stream-caller {
252  import run-stream;
253  export run;
254}
255
256world error-context-future-callee {
257  export run-future;
258  export run;
259}
260
261world error-context-future-caller {
262  import run-future;
263  export run;
264}
265
266world unit-stream-caller {
267  import unit-stream;
268  export run;
269}
270
271world unit-stream-callee {
272  export unit-stream;
273}
274
275world read-resource-stream {
276  import resource-stream;
277  export run;
278}
279
280world closed-streams {
281  export closed;
282}
283
284world sleep-host {
285  import sleep;
286}
287
288world cancel-caller {
289  import backpressure;
290  import sleep;
291  import sleep-with-options;
292  export cancel;
293}
294
295world cancel-callee {
296  import sleep;
297  export backpressure;
298  export sleep;
299  export sleep-with-options;
300}
301
302world cancel-host {
303  export cancel;
304}
305
306world intertask-communication {
307  import intertask;
308  export run;
309}
310