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 165interface readiness { 166 start: async func(s: stream<u8>, expected: list<u8>) -> tuple<stream<u8>, list<u8>>; 167} 168 169world yield-caller { 170 import continue; 171 import ready; 172 import run; 173 export run; 174} 175 176world yield-callee { 177 import continue; 178 export run; 179} 180 181world yield-host { 182 import continue; 183 import ready; 184 export run; 185} 186 187world poll { 188 import ready; 189 export run; 190} 191 192world backpressure-caller { 193 import backpressure; 194 import run; 195 export run; 196} 197 198world backpressure-callee { 199 export backpressure; 200 export run; 201} 202 203world transmit-caller { 204 import transmit; 205 export run; 206} 207 208world transmit-callee { 209 export transmit; 210} 211 212world post-return-caller { 213 import post-return; 214 export run; 215} 216 217world post-return-callee { 218 export post-return; 219} 220 221world borrowing-caller { 222 import borrowing; 223 export run-bool; 224} 225 226world borrowing-callee { 227 export borrowing; 228 export run-bool; 229} 230 231world borrowing-host { 232 import borrowing-types; 233 export run-bool; 234} 235 236world error-context-usage { 237 export run; 238} 239 240world error-context-callee { 241 export run-result; 242 export run; 243} 244 245world error-context-caller { 246 import run-result; 247 export run; 248} 249 250world error-context-stream-callee { 251 export run-stream; 252 export run; 253} 254 255world error-context-stream-caller { 256 import run-stream; 257 export run; 258} 259 260world error-context-future-callee { 261 export run-future; 262 export run; 263} 264 265world error-context-future-caller { 266 import run-future; 267 export run; 268} 269 270world unit-stream-caller { 271 import unit-stream; 272 export run; 273} 274 275world unit-stream-callee { 276 export unit-stream; 277} 278 279world read-resource-stream { 280 import resource-stream; 281 export run; 282} 283 284world closed-streams { 285 export closed; 286} 287 288world sleep-host { 289 import sleep; 290} 291 292world cancel-caller { 293 import backpressure; 294 import sleep; 295 import sleep-with-options; 296 export cancel; 297} 298 299world cancel-callee { 300 import sleep; 301 export backpressure; 302 export sleep; 303 export sleep-with-options; 304} 305 306world cancel-host { 307 export cancel; 308} 309 310world intertask-communication { 311 import intertask; 312 export run; 313} 314 315world readiness-guest { 316 export readiness; 317} 318