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: async 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: async 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 183interface short-reads { 184 resource thing { 185 constructor(s: string); 186 get: async func() -> string; 187 } 188 189 short-reads: async func(s: stream<thing>) -> stream<thing>; 190} 191 192world yield-caller { 193 import continue; 194 import ready; 195 import run; 196 export run; 197} 198 199world yield-callee { 200 import continue; 201 export run; 202} 203 204world yield-host { 205 import continue; 206 import ready; 207 export run; 208} 209 210world poll { 211 import ready; 212 export run; 213} 214 215world backpressure-caller { 216 import backpressure; 217 import run; 218 export run; 219} 220 221world backpressure-callee { 222 export backpressure; 223 export run; 224} 225 226world transmit-caller { 227 import transmit; 228 export run; 229} 230 231world transmit-callee { 232 export transmit; 233} 234 235world post-return-caller { 236 import post-return; 237 export run; 238} 239 240world post-return-callee { 241 export post-return; 242} 243 244world borrowing-caller { 245 import borrowing; 246 export run-bool; 247} 248 249world borrowing-callee { 250 export borrowing; 251 export run-bool; 252} 253 254world borrowing-host { 255 import borrowing-types; 256 export run-bool; 257} 258 259world error-context-usage { 260 export run; 261} 262 263world error-context-callee { 264 export run-result; 265 export run; 266} 267 268world error-context-caller { 269 import run-result; 270 export run; 271} 272 273world error-context-stream-callee { 274 export run-stream; 275 export run; 276} 277 278world error-context-stream-caller { 279 import run-stream; 280 export run; 281} 282 283world error-context-future-callee { 284 export run-future; 285 export run; 286} 287 288world error-context-future-caller { 289 import run-future; 290 export run; 291} 292 293world unit-stream-caller { 294 import unit-stream; 295 export run; 296} 297 298world unit-stream-callee { 299 export unit-stream; 300} 301 302world read-resource-stream { 303 import resource-stream; 304 export run; 305} 306 307world closed-streams { 308 export closed; 309} 310 311world sleep-host { 312 import sleep; 313} 314 315world cancel-caller { 316 import backpressure; 317 import sleep; 318 import sleep-with-options; 319 export cancel; 320} 321 322world cancel-callee { 323 import sleep; 324 export backpressure; 325 export sleep; 326 export sleep-with-options; 327} 328 329world cancel-host { 330 export cancel; 331} 332 333world intertask-communication { 334 import intertask; 335 export run; 336} 337 338world readiness-guest { 339 export readiness; 340} 341 342world synchronous-transmit-guest { 343 export synchronous-transmit; 344} 345 346world sleep-post-return-callee { 347 import sleep; 348 export sleep-post-return; 349} 350 351world sleep-post-return-caller { 352 import sleep; 353 import sleep-post-return; 354 export sleep-post-return; 355} 356 357world closed-stream-guest { 358 export closed-stream; 359} 360 361world short-reads-guest { 362 export short-reads; 363} 364