Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/codegen/expect/language/async_star_test_02_multi.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 dart_library.library('language/async_star_test_02_multi', null, /* Imports */[
2 'dart_sdk',
3 'unittest'
4 ], function load__async_star_test_02_multi(exports, dart_sdk, unittest) {
5 'use strict';
6 const core = dart_sdk.core;
7 const _interceptors = dart_sdk._interceptors;
8 const async = dart_sdk.async;
9 const dart = dart_sdk.dart;
10 const dartx = dart_sdk.dartx;
11 const unittest$ = unittest.unittest;
12 const src__matcher__expect = unittest.src__matcher__expect;
13 const src__matcher__core_matchers = unittest.src__matcher__core_matchers;
14 const src__matcher__numeric_matchers = unittest.src__matcher__numeric_matchers ;
15 const async_star_test_02_multi = Object.create(null);
16 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c ore.int)))();
17 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr ray$(core.Object)))();
18 let FutureOfObject = () => (FutureOfObject = dart.constFn(async.Future$(core.O bject)))();
19 let StreamOfObject = () => (StreamOfObject = dart.constFn(async.Stream$(core.O bject)))();
20 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr ray$(core.String)))();
21 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
22 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun ctionType(dart.dynamic, [dart.dynamic])))();
23 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT ype(dart.void, [dart.dynamic])))();
24 let VoidToFuture = () => (VoidToFuture = dart.constFn(dart.definiteFunctionTyp e(async.Future, [])))();
25 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
26 let VoidToObject = () => (VoidToObject = dart.constFn(dart.definiteFunctionTyp e(core.Object, [])))();
27 let VoidToFutureOfObject = () => (VoidToFutureOfObject = dart.constFn(dart.def initeFunctionType(FutureOfObject(), [])))();
28 let VoidToStreamOfObject = () => (VoidToStreamOfObject = dart.constFn(dart.def initeFunctionType(StreamOfObject(), [])))();
29 let dynamicToFuture = () => (dynamicToFuture = dart.constFn(dart.definiteFunct ionType(async.Future, [dart.dynamic])))();
30 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core .int, [])))();
31 let intTodynamic = () => (intTodynamic = dart.constFn(dart.definiteFunctionTyp e(dart.dynamic, [core.int])))();
32 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))();
33 let dynamicAndEventSinkTovoid = () => (dynamicAndEventSinkTovoid = dart.constF n(dart.definiteFunctionType(dart.void, [dart.dynamic, async.EventSink])))();
34 let ObjectAndStackTraceAndEventSinkTovoid = () => (ObjectAndStackTraceAndEvent SinkTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [core.Object, cor e.StackTrace, async.EventSink])))();
35 let EventSinkTovoid = () => (EventSinkTovoid = dart.constFn(dart.definiteFunct ionType(dart.void, [async.EventSink])))();
36 async_star_test_02_multi.main = function() {
37 unittest$.group("basic", dart.fn(() => {
38 unittest$.test("empty", dart.fn(() => {
39 function f() {
40 return dart.asyncStar(function*(stream) {
41 }, dart.dynamic);
42 }
43 dart.fn(f, VoidTodynamic());
44 return dart.dsend(dart.dsend(f(), 'toList'), 'then', dart.fn(v => {
45 src__matcher__expect.expect(v, src__matcher__core_matchers.equals([])) ;
46 }, dynamicTodynamic()));
47 }, VoidTodynamic()));
48 unittest$.test("single", dart.fn(() => {
49 function f() {
50 return dart.asyncStar(function*(stream) {
51 if (stream.add(42)) return;
52 yield;
53 }, dart.dynamic);
54 }
55 dart.fn(f, VoidTodynamic());
56 return dart.dsend(dart.dsend(f(), 'toList'), 'then', dart.fn(v => {
57 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(JSAr rayOfint().of([42])));
58 }, dynamicTodynamic()));
59 }, VoidTodynamic()));
60 unittest$.test("call delays", dart.fn(() => {
61 let list = [];
62 function f() {
63 return dart.asyncStar(function*(stream) {
64 list[dartx.add](1);
65 if (stream.add(2)) return;
66 yield;
67 }, dart.dynamic);
68 }
69 dart.fn(f, VoidTodynamic());
70 let res = dart.dsend(f(), 'forEach', dart.fn(x => list[dartx.add](x), dy namicTovoid()));
71 list[dartx.add](0);
72 return dart.dsend(res, 'whenComplete', dart.fn(() => {
73 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfint().of([0, 1, 2])));
74 }, VoidTodynamic()));
75 }, VoidTodynamic()));
76 unittest$.test("throws", dart.fn(() => {
77 function f() {
78 return dart.asyncStar(function*(stream) {
79 if (stream.add(1)) return;
80 yield;
81 dart.throw(2);
82 }, dart.dynamic);
83 }
84 dart.fn(f, VoidTodynamic());
85 let completer = async.Completer.new();
86 let list = [];
87 dart.dsend(f(), 'listen', dart.fn(x => list[dartx.add](x), dynamicTovoid ()), {onError: dart.fn(v => list[dartx.add](dart.str`${v}`), dynamicTovoid()), o nDone: dart.bind(completer, 'complete')});
88 return completer.future.whenComplete(dart.fn(() => {
89 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfObject().of([1, "2"])));
90 }, VoidTodynamic()));
91 }, VoidToFuture()));
92 unittest$.test("multiple", dart.fn(() => {
93 function f() {
94 return dart.asyncStar(function*(stream) {
95 for (let i = 0; i < 10; i++) {
96 if (stream.add(i)) return;
97 yield;
98 }
99 }, dart.dynamic);
100 }
101 dart.fn(f, VoidTodynamic());
102 return async_star_test_02_multi.expectList(f(), core.List.generate(10, a sync_star_test_02_multi.id));
103 }, VoidTodynamic()));
104 unittest$.test("allows await", dart.fn(() => {
105 function f() {
106 return dart.asyncStar(function*(stream) {
107 let x = (yield async.Future.value(42));
108 if (stream.add(x)) return;
109 yield;
110 x = (yield async.Future.value(42));
111 }, dart.dynamic);
112 }
113 dart.fn(f, VoidTodynamic());
114 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
115 }, VoidTodynamic()));
116 unittest$.test("allows await in loop", dart.fn(() => {
117 function f() {
118 return dart.asyncStar(function*(stream) {
119 for (let i = 0; i < 10; i++) {
120 if (stream.add(yield i)) return;
121 yield;
122 }
123 }, dart.dynamic);
124 }
125 dart.fn(f, VoidTodynamic());
126 return async_star_test_02_multi.expectList(f(), core.List.generate(10, a sync_star_test_02_multi.id));
127 }, VoidTodynamic()));
128 unittest$.test("allows yield*", dart.fn(() => {
129 function f() {
130 return dart.asyncStar(function*(stream) {
131 if (stream.addStream(async.Stream.fromIterable(JSArrayOfint().of([1, 2, 3])))) return;
132 yield;
133 }, dart.dynamic);
134 }
135 dart.fn(f, VoidTodynamic());
136 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([1, 2, 3]));
137 }, VoidTodynamic()));
138 unittest$.test("allows yield* of async*", dart.fn(() => {
139 function f(n) {
140 return dart.asyncStar(function*(stream, n) {
141 if (stream.add(n)) return;
142 yield;
143 if (dart.equals(n, 0)) return;
144 if (stream.addStream(async.Stream._check(f(dart.dsend(n, '-', 1))))) return;
145 yield;
146 if (stream.add(n)) return;
147 yield;
148 }, dart.dynamic, n);
149 }
150 dart.fn(f, dynamicTodynamic());
151 return async_star_test_02_multi.expectList(f(3), JSArrayOfint().of([3, 2 , 1, 0, 1, 2, 3]));
152 }, VoidTodynamic()));
153 unittest$.test("Cannot yield* non-stream", dart.fn(() => {
154 function f(s) {
155 return dart.asyncStar(function*(stream, s) {
156 if (stream.addStream(async.Stream._check(s))) return;
157 yield;
158 }, dart.dynamic, s);
159 }
160 dart.fn(f, dynamicTodynamic());
161 return dart.dsend(dart.dload(dart.dsend(f(42), 'transform', async_star_t est_02_multi.getErrors), 'single'), 'then', dart.fn(v => {
162 src__matcher__expect.expect(core.Error.is(v), src__matcher__core_match ers.isTrue);
163 }, dynamicTodynamic()));
164 }, VoidTodynamic()));
165 unittest$.test("Cannot yield* non-stream", dart.fn(() => {
166 function f(s) {
167 return dart.asyncStar(function*(stream, s) {
168 if (stream.addStream(async.Stream._check(s))) return;
169 yield;
170 }, dart.dynamic, s);
171 }
172 dart.fn(f, dynamicTodynamic());
173 return dart.dsend(dart.dload(dart.dsend(f(new async_star_test_02_multi.N otAStream()), 'transform', async_star_test_02_multi.getErrors), 'single'), 'then ', dart.fn(v => {
174 src__matcher__expect.expect(core.Error.is(v), src__matcher__core_match ers.isTrue);
175 }, dynamicTodynamic()));
176 }, VoidTodynamic()));
177 }, VoidTovoid()));
178 unittest$.group("yield statement context", dart.fn(() => {
179 unittest$.test("plain", dart.fn(() => {
180 function f() {
181 return dart.asyncStar(function*(stream) {
182 if (stream.add(0)) return;
183 yield;
184 }, dart.dynamic);
185 }
186 dart.fn(f, VoidTodynamic());
187 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0]));
188 }, VoidTodynamic()));
189 unittest$.test("if-then-else", dart.fn(() => {
190 function f(b) {
191 return dart.asyncStar(function*(stream, b) {
192 if (dart.test(b)) {
193 if (stream.add(0)) return;
194 yield;
195 } else {
196 if (stream.add(1)) return;
197 yield;
198 }
199 }, dart.dynamic, b);
200 }
201 dart.fn(f, dynamicTodynamic());
202 return dart.dsend(async_star_test_02_multi.expectList(f(true), JSArrayOf int().of([0])), 'whenComplete', dart.fn(() => {
203 async_star_test_02_multi.expectList(f(false), JSArrayOfint().of([1]));
204 }, VoidTodynamic()));
205 }, VoidTodynamic()));
206 unittest$.test("block", dart.fn(() => {
207 function f() {
208 return dart.asyncStar(function*(stream) {
209 if (stream.add(0)) return;
210 yield;
211 {
212 if (stream.add(1)) return;
213 yield;
214 }
215 if (stream.add(2)) return;
216 yield;
217 }, dart.dynamic);
218 }
219 dart.fn(f, VoidTodynamic());
220 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2]));
221 }, VoidTodynamic()));
222 unittest$.test("labeled", dart.fn(() => {
223 function f() {
224 return dart.asyncStar(function*(stream) {
225 label1: {
226 if (stream.add(0)) return;
227 yield;
228 }
229 }, dart.dynamic);
230 }
231 dart.fn(f, VoidTodynamic());
232 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0]));
233 }, VoidTodynamic()));
234 unittest$.test("for-loop", dart.fn(() => {
235 function f() {
236 return dart.asyncStar(function*(stream) {
237 for (let i = 0; i < 3; i++) {
238 if (stream.add(i)) return;
239 yield;
240 }
241 }, dart.dynamic);
242 }
243 dart.fn(f, VoidTodynamic());
244 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2]));
245 }, VoidTodynamic()));
246 unittest$.test("for-in-loop", dart.fn(() => {
247 function f() {
248 return dart.asyncStar(function*(stream) {
249 for (let i of JSArrayOfint().of([0, 1, 2])) {
250 if (stream.add(i)) return;
251 yield;
252 }
253 }, dart.dynamic);
254 }
255 dart.fn(f, VoidTodynamic());
256 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2]));
257 }, VoidTodynamic()));
258 unittest$.test("await for-in-loop", dart.fn(() => {
259 function f() {
260 return dart.asyncStar(function*(stream) {
261 let it = async.StreamIterator.new(async.Stream.fromIterable(JSArrayO fint().of([0, 1, 2])));
262 try {
263 while (yield it.moveNext()) {
264 let i = it.current;
265 if (stream.add(i)) return;
266 yield;
267 }
268 } finally {
269 yield it.cancel();
270 }
271 }, dart.dynamic);
272 }
273 dart.fn(f, VoidTodynamic());
274 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2]));
275 }, VoidTodynamic()));
276 unittest$.test("while-loop", dart.fn(() => {
277 function f() {
278 return dart.asyncStar(function*(stream) {
279 let i = 0;
280 while (i < 3) {
281 if (stream.add(i++)) return;
282 yield;
283 }
284 }, dart.dynamic);
285 }
286 dart.fn(f, VoidTodynamic());
287 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2]));
288 }, VoidTodynamic()));
289 unittest$.test("do-while-loop", dart.fn(() => {
290 function f() {
291 return dart.asyncStar(function*(stream) {
292 let i = 0;
293 do {
294 if (stream.add(i++)) return;
295 yield;
296 } while (i < 3);
297 }, dart.dynamic);
298 }
299 dart.fn(f, VoidTodynamic());
300 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2]));
301 }, VoidTodynamic()));
302 unittest$.test("try-catch-finally", dart.fn(() => {
303 function f() {
304 return dart.asyncStar(function*(stream) {
305 try {
306 if (stream.add(0)) return;
307 yield;
308 } catch (e) {
309 if (stream.add(1)) return;
310 yield;
311 }
312 finally {
313 if (stream.add(2)) return;
314 yield;
315 }
316 }, dart.dynamic);
317 }
318 dart.fn(f, VoidTodynamic());
319 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 2] ));
320 }, VoidTodynamic()));
321 unittest$.test("try-catch-finally 2", dart.fn(() => {
322 function f() {
323 return dart.asyncStar(function*(stream) {
324 try {
325 if (stream.add(dart.throw(0))) return;
326 yield;
327 } catch (e) {
328 if (stream.add(1)) return;
329 yield;
330 }
331 finally {
332 if (stream.add(2)) return;
333 yield;
334 }
335 }, dart.dynamic);
336 }
337 dart.fn(f, VoidTodynamic());
338 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([1, 2] ));
339 }, VoidTodynamic()));
340 unittest$.test("dead-code return", dart.fn(() => {
341 function f() {
342 return dart.asyncStar(function*(stream) {
343 return;
344 if (stream.add(1)) return;
345 yield;
346 }, dart.dynamic);
347 }
348 dart.fn(f, VoidTodynamic());
349 return async_star_test_02_multi.expectList(f(), []);
350 }, VoidTodynamic()));
351 unittest$.test("dead-code throw", dart.fn(() => {
352 function f() {
353 return dart.asyncStar(function*(stream) {
354 try {
355 dart.throw(0);
356 if (stream.add(1)) return;
357 yield;
358 } catch (_) {
359 }
360
361 }, dart.dynamic);
362 }
363 dart.fn(f, VoidTodynamic());
364 return async_star_test_02_multi.expectList(f(), []);
365 }, VoidTodynamic()));
366 unittest$.test("dead-code break", dart.fn(() => {
367 function f() {
368 return dart.asyncStar(function*(stream) {
369 while (true) {
370 break;
371 if (stream.add(1)) return;
372 yield;
373 }
374 }, dart.dynamic);
375 }
376 dart.fn(f, VoidTodynamic());
377 return async_star_test_02_multi.expectList(f(), []);
378 }, VoidTodynamic()));
379 unittest$.test("dead-code break 2", dart.fn(() => {
380 function f() {
381 return dart.asyncStar(function*(stream) {
382 label: {
383 break label;
384 if (stream.add(1)) return;
385 yield;
386 }
387 }, dart.dynamic);
388 }
389 dart.fn(f, VoidTodynamic());
390 return async_star_test_02_multi.expectList(f(), []);
391 }, VoidTodynamic()));
392 unittest$.test("dead-code continue", dart.fn(() => {
393 function f() {
394 return dart.asyncStar(function*(stream) {
395 do {
396 continue;
397 if (stream.add(1)) return;
398 yield;
399 } while (false);
400 }, dart.dynamic);
401 }
402 dart.fn(f, VoidTodynamic());
403 return async_star_test_02_multi.expectList(f(), []);
404 }, VoidTodynamic()));
405 }, VoidTovoid()));
406 unittest$.group("yield expressions", dart.fn(() => {
407 unittest$.test("local variable", dart.fn(() => {
408 function f() {
409 return dart.asyncStar(function*(stream) {
410 let x = 42;
411 if (stream.add(x)) return;
412 yield;
413 }, dart.dynamic);
414 }
415 dart.fn(f, VoidTodynamic());
416 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
417 }, VoidTodynamic()));
418 unittest$.test("constant variable", dart.fn(() => {
419 function f() {
420 return dart.asyncStar(function*(stream) {
421 let x = 42;
422 if (stream.add(x)) return;
423 yield;
424 }, dart.dynamic);
425 }
426 dart.fn(f, VoidTodynamic());
427 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
428 }, VoidTodynamic()));
429 unittest$.test("function call", dart.fn(() => {
430 function g() {
431 return 42;
432 }
433 dart.fn(g, VoidTodynamic());
434 function f() {
435 return dart.asyncStar(function*(stream) {
436 if (stream.add(g())) return;
437 yield;
438 }, dart.dynamic);
439 }
440 dart.fn(f, VoidTodynamic());
441 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
442 }, VoidTodynamic()));
443 unittest$.test("unary operator", dart.fn(() => {
444 function f() {
445 return dart.asyncStar(function*(stream) {
446 let x = -42;
447 if (stream.add(-x)) return;
448 yield;
449 }, dart.dynamic);
450 }
451 dart.fn(f, VoidTodynamic());
452 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
453 }, VoidTodynamic()));
454 unittest$.test("binary operator", dart.fn(() => {
455 function f() {
456 return dart.asyncStar(function*(stream) {
457 let x = 21;
458 if (stream.add(x + x)) return;
459 yield;
460 }, dart.dynamic);
461 }
462 dart.fn(f, VoidTodynamic());
463 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
464 }, VoidTodynamic()));
465 unittest$.test("ternary operator", dart.fn(() => {
466 function f() {
467 return dart.asyncStar(function*(stream) {
468 let x = 21;
469 if (stream.add(x == 21 ? x + x : x)) return;
470 yield;
471 }, dart.dynamic);
472 }
473 dart.fn(f, VoidTodynamic());
474 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
475 }, VoidTodynamic()));
476 unittest$.test("suffix post-increment", dart.fn(() => {
477 function f() {
478 return dart.asyncStar(function*(stream) {
479 let x = 42;
480 if (stream.add(x++)) return;
481 yield;
482 }, dart.dynamic);
483 }
484 dart.fn(f, VoidTodynamic());
485 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
486 }, VoidTodynamic()));
487 unittest$.test("suffix pre-increment", dart.fn(() => {
488 function f() {
489 return dart.asyncStar(function*(stream) {
490 let x = 41;
491 if (stream.add(++x)) return;
492 yield;
493 }, dart.dynamic);
494 }
495 dart.fn(f, VoidTodynamic());
496 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
497 }, VoidTodynamic()));
498 unittest$.test("assignment", dart.fn(() => {
499 function f() {
500 return dart.asyncStar(function*(stream) {
501 let x = 37;
502 if (stream.add(x = 42)) return;
503 yield;
504 }, dart.dynamic);
505 }
506 dart.fn(f, VoidTodynamic());
507 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
508 }, VoidTodynamic()));
509 unittest$.test("assignment op", dart.fn(() => {
510 function f() {
511 return dart.asyncStar(function*(stream) {
512 let x = 41;
513 if (stream.add((x = x + 1))) return;
514 yield;
515 }, dart.dynamic);
516 }
517 dart.fn(f, VoidTodynamic());
518 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
519 }, VoidTodynamic()));
520 unittest$.test("await", dart.fn(() => {
521 function f() {
522 return dart.asyncStar(function*(stream) {
523 if (stream.add(yield async.Future.value(42))) return;
524 yield;
525 }, dart.dynamic);
526 }
527 dart.fn(f, VoidTodynamic());
528 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
529 }, VoidTodynamic()));
530 unittest$.test("index operator", dart.fn(() => {
531 function f() {
532 return dart.asyncStar(function*(stream) {
533 let x = JSArrayOfint().of([42]);
534 if (stream.add(x[dartx.get](0))) return;
535 yield;
536 }, dart.dynamic);
537 }
538 dart.fn(f, VoidTodynamic());
539 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42])) ;
540 }, VoidTodynamic()));
541 unittest$.test("function expression block", dart.fn(() => {
542 let o = new core.Object();
543 function f() {
544 return dart.asyncStar(function*(stream) {
545 if (stream.add(dart.fn(() => o, VoidToObject()))) return;
546 yield;
547 }, dart.dynamic);
548 }
549 dart.fn(f, VoidTodynamic());
550 return dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v => {
551 src__matcher__expect.expect(dart.dcall(v), src__matcher__core_matchers .same(o));
552 }, dynamicTodynamic()));
553 }, VoidTodynamic()));
554 unittest$.test("function expression arrow", dart.fn(() => {
555 let o = new core.Object();
556 function f() {
557 return dart.asyncStar(function*(stream) {
558 if (stream.add(dart.fn(() => o, VoidToObject()))) return;
559 yield;
560 }, dart.dynamic);
561 }
562 dart.fn(f, VoidTodynamic());
563 return dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v => {
564 src__matcher__expect.expect(dart.dcall(v), src__matcher__core_matchers .same(o));
565 }, dynamicTodynamic()));
566 }, VoidTodynamic()));
567 unittest$.test("function expression block async", dart.fn(() => {
568 let o = new core.Object();
569 function f() {
570 return dart.asyncStar(function*(stream) {
571 if (stream.add(dart.fn(() => dart.async(function*() {
572 return o;
573 }, core.Object), VoidToFutureOfObject()))) return;
574 yield;
575 }, dart.dynamic);
576 }
577 dart.fn(f, VoidTodynamic());
578 return dart.dsend(dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v => dart.dcall(v), dynamicTodynamic())), 'then', dart.fn(v => {
579 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o));
580 }, dynamicTodynamic()));
581 }, VoidTodynamic()));
582 unittest$.test("function expression arrow async", dart.fn(() => {
583 let o = new core.Object();
584 function f() {
585 return dart.asyncStar(function*(stream) {
586 if (stream.add(dart.fn(() => dart.async(function*() {
587 return o;
588 }, core.Object), VoidToFutureOfObject()))) return;
589 yield;
590 }, dart.dynamic);
591 }
592 dart.fn(f, VoidTodynamic());
593 return dart.dsend(dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v => dart.dcall(v), dynamicTodynamic())), 'then', dart.fn(v => {
594 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o));
595 }, dynamicTodynamic()));
596 }, VoidTodynamic()));
597 unittest$.test("function expression block async*", dart.fn(() => {
598 let o = new core.Object();
599 function f() {
600 return dart.asyncStar(function*(stream) {
601 if (stream.add(dart.fn(() => dart.asyncStar(function*(stream) {
602 if (stream.add(o)) return;
603 yield;
604 }, core.Object), VoidToStreamOfObject()))) return;
605 yield;
606 }, dart.dynamic);
607 }
608 dart.fn(f, VoidTodynamic());
609 return dart.dsend(dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v => dart.dload(dart.dcall(v), 'first'), dynamicTodynamic())), 'then', dart.fn(v => {
610 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o));
611 }, dynamicTodynamic()));
612 }, VoidTodynamic()));
613 }, VoidTovoid()));
614 unittest$.group("loops", dart.fn(() => {
615 unittest$.test("simple yield", dart.fn(() => {
616 function f() {
617 return dart.asyncStar(function*(stream) {
618 for (let i = 0; i < 3; i++) {
619 if (stream.add(i)) return;
620 yield;
621 }
622 }, dart.dynamic);
623 }
624 dart.fn(f, VoidTodynamic());
625 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2]));
626 }, VoidTodynamic()));
627 unittest$.test("yield in double loop", dart.fn(() => {
628 function f() {
629 return dart.asyncStar(function*(stream) {
630 for (let i = 0; i < 3; i++) {
631 for (let j = 0; j < 2; j++) {
632 if (stream.add(i * 2 + j)) return;
633 yield;
634 }
635 }
636 }, dart.dynamic);
637 }
638 dart.fn(f, VoidTodynamic());
639 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1, 2, 3, 4, 5]));
640 }, VoidTodynamic()));
641 unittest$.test("yield in try body", dart.fn(() => {
642 let list = [];
643 function f() {
644 return dart.asyncStar(function*(stream) {
645 for (let i = 0; i < 3; i++) {
646 try {
647 if (stream.add(i)) return;
648 yield;
649 } finally {
650 list[dartx.add](dart.str`${i}`);
651 }
652 }
653 }, dart.dynamic);
654 }
655 dart.fn(f, VoidTodynamic());
656 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint( ).of([0, 1, 2])), 'whenComplete', dart.fn(() => {
657 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfString().of(["0", "1", "2"])));
658 }, VoidTodynamic()));
659 }, VoidTodynamic()));
660 unittest$.test("yield in catch", dart.fn(() => {
661 let list = [];
662 function f() {
663 return dart.asyncStar(function*(stream) {
664 for (let i = 0; i < 3; i++) {
665 try {
666 dart.throw(i);
667 } catch (e) {
668 if (stream.add(e)) return;
669 yield;
670 }
671 finally {
672 list[dartx.add](dart.str`${i}`);
673 }
674 }
675 }, dart.dynamic);
676 }
677 dart.fn(f, VoidTodynamic());
678 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint( ).of([0, 1, 2])), 'whenComplete', dart.fn(() => {
679 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfString().of(["0", "1", "2"])));
680 }, VoidTodynamic()));
681 }, VoidTodynamic()));
682 unittest$.test("yield in finally", dart.fn(() => {
683 let list = [];
684 function f() {
685 return dart.asyncStar(function*(stream) {
686 for (let i = 0; i < 3; i++) {
687 try {
688 dart.throw(i);
689 } finally {
690 if (stream.add(i)) return;
691 yield;
692 list[dartx.add](dart.str`${i}`);
693 continue;
694 }
695 }
696 }, dart.dynamic);
697 }
698 dart.fn(f, VoidTodynamic());
699 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint( ).of([0, 1, 2])), 'whenComplete', dart.fn(() => {
700 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfString().of(["0", "1", "2"])));
701 }, VoidTodynamic()));
702 }, VoidTodynamic()));
703 unittest$.test("keep yielding after cancel", dart.fn(() => {
704 function f() {
705 return dart.asyncStar(function*(stream) {
706 for (let i = 0; i < 10; i++) {
707 try {
708 if (stream.add(i)) return;
709 yield;
710 } finally {
711 continue;
712 }
713 }
714 }, dart.dynamic);
715 }
716 dart.fn(f, VoidTodynamic());
717 return async_star_test_02_multi.expectList(dart.dsend(f(), 'take', 3), J SArrayOfint().of([0, 1, 2]));
718 }, VoidTodynamic()));
719 }, VoidTovoid()));
720 unittest$.group("canceling", dart.fn(() => {
721 unittest$.test("cancels at yield", dart.fn(() => {
722 let exits = async.Completer.new();
723 let list = [];
724 function f() {
725 return dart.asyncStar(function*(stream) {
726 try {
727 list[dartx.add](0);
728 if (stream.add(list[dartx.add](1))) return;
729 yield;
730 list[dartx.add](2);
731 } finally {
732 exits.complete(3);
733 }
734 }, dart.dynamic);
735 }
736 dart.fn(f, VoidTodynamic());
737 let subscription = dart.dsend(f(), 'listen', dart.fn(v => {
738 src__matcher__expect.fail(dart.str`Received event ${v}`);
739 }, dynamicTodynamic()), {onDone: dart.fn(() => {
740 src__matcher__expect.fail("Received done");
741 }, VoidTodynamic())});
742 dart.dsend(subscription, 'cancel');
743 return exits.future.then(dart.dynamic)(dart.fn(v => {
744 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(3));
745 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfint().of([0, 1])));
746 }, dynamicTodynamic()));
747 }, VoidToFuture()));
748 unittest$.test("does cancel eventually", dart.fn(() => {
749 let exits = async.Completer.new();
750 let list = [];
751 function f() {
752 return dart.asyncStar(function*(stream) {
753 let i = 0;
754 try {
755 while (true) {
756 if (stream.add(i++)) return;
757 yield;
758 }
759 } finally {
760 list[dartx.add]("a");
761 exits.complete(i);
762 }
763 }, dart.dynamic);
764 }
765 dart.fn(f, VoidTodynamic());
766 return dart.dsend(dart.dsend(async_star_test_02_multi.expectList(dart.ds end(f(), 'take', 5), JSArrayOfint().of([0, 1, 2, 3, 4])), 'then', dart.fn(_ => e xits.future, dynamicToFuture())), 'then', dart.fn(v => {
767 src__matcher__expect.expect(v, src__matcher__numeric_matchers.greaterT han(4));
768 src__matcher__expect.expect(list, JSArrayOfString().of(["a"]));
769 }, dynamicTodynamic()));
770 }, VoidTodynamic()));
771 unittest$.group("at index", dart.fn(() => {
772 function f() {
773 return dart.asyncStar(function*(stream) {
774 try {
775 if (stream.add(yield async.Future.microtask(dart.fn(() => 1, VoidT oint())))) return;
776 yield;
777 } finally {
778 try {
779 if (stream.add(yield async.Future.microtask(dart.fn(() => 2, Voi dToint())))) return;
780 yield;
781 } finally {
782 if (stream.add(yield async.Future.microtask(dart.fn(() => 3, Voi dToint())))) return;
783 yield;
784 }
785 }
786 }, dart.dynamic);
787 }
788 dart.fn(f, VoidTodynamic());
789 unittest$.test("- all, sanity check", dart.fn(() => async_star_test_02_m ulti.expectList(f(), JSArrayOfint().of([1, 2, 3])), VoidTodynamic()));
790 unittest$.test("after end", dart.fn(() => async_star_test_02_multi.expec tList(dart.dsend(f(), 'take', 4), JSArrayOfint().of([1, 2, 3])), VoidTodynamic() ));
791 unittest$.test("at end", dart.fn(() => async_star_test_02_multi.expectLi st(dart.dsend(f(), 'take', 3), JSArrayOfint().of([1, 2, 3])), VoidTodynamic()));
792 unittest$.test("before end", dart.fn(() => async_star_test_02_multi.expe ctList(dart.dsend(f(), 'take', 2), JSArrayOfint().of([1, 2])), VoidTodynamic())) ;
793 unittest$.test("early", dart.fn(() => async_star_test_02_multi.expectLis t(dart.dsend(f(), 'take', 1), JSArrayOfint().of([1])), VoidTodynamic()));
794 unittest$.test("at start", dart.fn(() => async_star_test_02_multi.expect List(dart.dsend(f(), 'take', 0), []), VoidTodynamic()));
795 }, VoidTovoid()));
796 }, VoidTovoid()));
797 unittest$.group("pausing", dart.fn(() => {
798 unittest$.test("pauses execution at yield for at least a microtask", dart. fn(() => {
799 let list = [];
800 function f() {
801 return dart.asyncStar(function*(stream) {
802 list[dartx.add](1);
803 if (stream.add(2)) return;
804 yield;
805 list[dartx.add](3);
806 if (stream.add(4)) return;
807 yield;
808 list[dartx.add](5);
809 }, dart.dynamic);
810 }
811 dart.fn(f, VoidTodynamic());
812 let done = async.Completer.new();
813 let sub = dart.dsend(f(), 'listen', dart.fn(v => {
814 if (dart.equals(v, 2)) {
815 src__matcher__expect.expect(list, src__matcher__core_matchers.equals (JSArrayOfint().of([1])));
816 } else if (dart.equals(v, 4)) {
817 src__matcher__expect.expect(list, src__matcher__core_matchers.equals (JSArrayOfint().of([1, 3])));
818 } else {
819 src__matcher__expect.fail(dart.str`Unexpected value ${v}`);
820 }
821 }, dynamicTodynamic()), {onDone: dart.fn(() => {
822 src__matcher__expect.expect(list, src__matcher__core_matchers.equals (JSArrayOfint().of([1, 3, 5])));
823 done.complete();
824 }, VoidTodynamic())});
825 return done.future;
826 }, VoidToFuture()));
827 unittest$.test("pause stops execution at yield", dart.fn(() => {
828 let list = [];
829 function f() {
830 return dart.asyncStar(function*(stream) {
831 list[dartx.add](1);
832 if (stream.add(2)) return;
833 yield;
834 list[dartx.add](3);
835 if (stream.add(4)) return;
836 yield;
837 list[dartx.add](5);
838 }, dart.dynamic);
839 }
840 dart.fn(f, VoidTodynamic());
841 let done = async.Completer.new();
842 let sub = null;
843 sub = dart.dsend(f(), 'listen', dart.fn(v => {
844 if (dart.equals(v, 2)) {
845 src__matcher__expect.expect(list, src__matcher__core_matchers.equals (JSArrayOfint().of([1])));
846 dart.dsend(sub, 'pause');
847 async.Timer.new(async_star_test_02_multi.MS['*'](300), dart.fn(() => {
848 src__matcher__expect.expect(list[dartx.length], src__matcher__nume ric_matchers.lessThan(3));
849 dart.dsend(sub, 'resume');
850 }, VoidTovoid()));
851 } else if (dart.equals(v, 4)) {
852 src__matcher__expect.expect(list, src__matcher__core_matchers.equals (JSArrayOfint().of([1, 3])));
853 } else {
854 src__matcher__expect.fail(dart.str`Unexpected value ${v}`);
855 }
856 }, dynamicTodynamic()), {onDone: dart.fn(() => {
857 src__matcher__expect.expect(list, src__matcher__core_matchers.equals (JSArrayOfint().of([1, 3, 5])));
858 done.complete();
859 }, VoidTodynamic())});
860 return done.future;
861 }, VoidToFuture()));
862 unittest$.test("pause stops execution at yield 2", dart.fn(() => {
863 let list = [];
864 function f() {
865 return dart.asyncStar(function*(stream) {
866 let i = 0;
867 while (true) {
868 if (stream.add(i)) return;
869 yield;
870 list[dartx.add](i);
871 i++;
872 }
873 }, dart.dynamic);
874 }
875 dart.fn(f, VoidTodynamic());
876 let expected = 0;
877 let done = async.Completer.new();
878 let sub = null;
879 sub = dart.dsend(f(), 'listen', dart.fn(v => {
880 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(expe cted++));
881 if (dart.equals(dart.dsend(v, '%', 5), 0)) {
882 dart.dsend(sub, 'pause', async.Future.delayed(async_star_test_02_mul ti.MS['*'](300)));
883 } else if (dart.equals(v, 17)) {
884 dart.dsend(sub, 'cancel');
885 done.complete();
886 }
887 }, dynamicTodynamic()), {onDone: dart.fn(() => {
888 src__matcher__expect.fail("Unexpected done!");
889 }, VoidTodynamic())});
890 return done.future.whenComplete(dart.fn(() => {
891 src__matcher__expect.expect(list[dartx.length] == 18 || list[dartx.len gth] == 19, src__matcher__core_matchers.isTrue);
892 }, VoidTodynamic()));
893 }, VoidToFuture()));
894 unittest$.test("canceling while paused at yield", dart.fn(() => {
895 let list = [];
896 let sync = new async_star_test_02_multi.Sync();
897 function f() {
898 return dart.asyncStar(function*(stream) {
899 list[dartx.add]("*1");
900 if (stream.add(1)) return;
901 yield;
902 yield sync.wait();
903 sync.release();
904 list[dartx.add]("*2");
905 if (stream.add(2)) return;
906 yield;
907 list[dartx.add]("*3");
908 }, dart.dynamic);
909 }
910 dart.fn(f, VoidTodynamic());
911 ;
912 let stream = f();
913 let sub = dart.dsend(stream, 'listen', dart.fn(x => list[dartx.add](x), dynamicTovoid()));
914 return sync.wait().whenComplete(dart.fn(() => {
915 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfObject().of(["*1", 1])));
916 dart.dsend(sub, 'pause');
917 return sync.wait();
918 }, VoidToFuture())).whenComplete(dart.fn(() => {
919 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J SArrayOfObject().of(["*1", 1, "*2"])));
920 dart.dsend(sub, 'cancel');
921 return async.Future.delayed(async_star_test_02_multi.MS['*'](200), dar t.fn(() => {
922 src__matcher__expect.expect(list, src__matcher__core_matchers.equals (JSArrayOfObject().of(["*1", 1, "*2"])));
923 }, VoidTodynamic()));
924 }, VoidToFuture()));
925 }, VoidToFuture()));
926 }, VoidTovoid()));
927 unittest$.group("await for", dart.fn(() => {
928 function mkStream(n) {
929 return dart.asyncStar(function*(stream, n) {
930 for (let i = 0; i < dart.notNull(n); i++) {
931 if (stream.add(i)) return;
932 yield;
933 }
934 }, dart.dynamic, n);
935 }
936 dart.fn(mkStream, intTodynamic());
937 unittest$.test("simple stream", dart.fn(() => {
938 function f(s) {
939 return dart.async(function*(s) {
940 let r = 0;
941 let it = async.StreamIterator.new(async.Stream._check(s));
942 try {
943 while (yield it.moveNext()) {
944 let v = it.current;
945 r = dart.notNull(r) + dart.notNull(core.int._check(v));
946 }
947 } finally {
948 yield it.cancel();
949 }
950 return r;
951 }, dart.dynamic, s);
952 }
953 dart.fn(f, dynamicTodynamic());
954 return dart.dsend(f(mkStream(5)), 'then', dart.fn(v => {
955 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10)) ;
956 }, dynamicTodynamic()));
957 }, VoidTodynamic()));
958 unittest$.test("simple stream, await", dart.fn(() => {
959 function f(s) {
960 return dart.async(function*(s) {
961 let r = 0;
962 let it = async.StreamIterator.new(async.Stream._check(s));
963 try {
964 while (yield it.moveNext()) {
965 let v = it.current;
966 r = dart.notNull(r) + dart.notNull(core.int._check(yield async.F uture.microtask(dart.fn(() => v, VoidTodynamic()))));
967 }
968 } finally {
969 yield it.cancel();
970 }
971 return r;
972 }, dart.dynamic, s);
973 }
974 dart.fn(f, dynamicTodynamic());
975 return dart.dsend(f(mkStream(5)), 'then', dart.fn(v => {
976 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10)) ;
977 }, dynamicTodynamic()));
978 }, VoidTodynamic()));
979 unittest$.test("simple stream reyield", dart.fn(() => {
980 function f(s) {
981 return dart.asyncStar(function*(stream, s) {
982 let r = 0;
983 let it = async.StreamIterator.new(async.Stream._check(s));
984 try {
985 while (yield it.moveNext()) {
986 let v = it.current;
987 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che ck(v))))) return;
988 yield;
989 }
990 } finally {
991 yield it.cancel();
992 }
993 }, dart.dynamic, s);
994 }
995 dart.fn(f, dynamicTodynamic());
996 return async_star_test_02_multi.expectList(f(mkStream(5)), JSArrayOfint( ).of([0, 1, 3, 6, 10]));
997 }, VoidTodynamic()));
998 unittest$.test("simple stream, await, reyield", dart.fn(() => {
999 function f(s) {
1000 return dart.asyncStar(function*(stream, s) {
1001 let r = 0;
1002 let it = async.StreamIterator.new(async.Stream._check(s));
1003 try {
1004 while (yield it.moveNext()) {
1005 let v = it.current;
1006 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che ck(yield async.Future.microtask(dart.fn(() => v, VoidTodynamic()))))))) return;
1007 yield;
1008 }
1009 } finally {
1010 yield it.cancel();
1011 }
1012 }, dart.dynamic, s);
1013 }
1014 dart.fn(f, dynamicTodynamic());
1015 return async_star_test_02_multi.expectList(f(mkStream(5)), JSArrayOfint( ).of([0, 1, 3, 6, 10]));
1016 }, VoidTodynamic()));
1017 unittest$.test("nested", dart.fn(() => {
1018 function f() {
1019 return dart.async(function*() {
1020 let r = 0;
1021 let it = async.StreamIterator.new(async.Stream._check(mkStream(5)));
1022 try {
1023 while (yield it.moveNext()) {
1024 let i = it.current;
1025 let it$ = async.StreamIterator.new(async.Stream._check(mkStream( 3)));
1026 try {
1027 while (yield it$.moveNext()) {
1028 let j = it$.current;
1029 r = dart.notNull(r) + dart.notNull(core.int._check(dart.dsen d(i, '*', j)));
1030 }
1031 } finally {
1032 yield it$.cancel();
1033 }
1034 }
1035 } finally {
1036 yield it.cancel();
1037 }
1038 return r;
1039 }, dart.dynamic);
1040 }
1041 dart.fn(f, VoidTodynamic());
1042 return dart.dsend(f(), 'then', dart.fn(v => {
1043 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 + 2 + 3 + 4) * (1 + 2)));
1044 }, dynamicTodynamic()));
1045 }, VoidTodynamic()));
1046 unittest$.test("nested, await", dart.fn(() => {
1047 function f() {
1048 return dart.async(function*() {
1049 let r = 0;
1050 let it = async.StreamIterator.new(async.Stream._check(mkStream(5)));
1051 try {
1052 while (yield it.moveNext()) {
1053 let i = it.current;
1054 let it$ = async.StreamIterator.new(async.Stream._check(mkStream( 3)));
1055 try {
1056 while (yield it$.moveNext()) {
1057 let j = it$.current;
1058 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy nc.Future.microtask(dart.fn(() => dart.dsend(i, '*', j), VoidTodynamic()))));
1059 }
1060 } finally {
1061 yield it$.cancel();
1062 }
1063 }
1064 } finally {
1065 yield it.cancel();
1066 }
1067 return r;
1068 }, dart.dynamic);
1069 }
1070 dart.fn(f, VoidTodynamic());
1071 return dart.dsend(f(), 'then', dart.fn(v => {
1072 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 + 2 + 3 + 4) * (1 + 2)));
1073 }, dynamicTodynamic()));
1074 }, VoidTodynamic()));
1075 unittest$.test("nested, await * 2", dart.fn(() => {
1076 function f() {
1077 return dart.async(function*() {
1078 let r = 0;
1079 let it = async.StreamIterator.new(async.Stream._check(mkStream(5)));
1080 try {
1081 while (yield it.moveNext()) {
1082 let i = it.current;
1083 let ai = (yield async.Future.microtask(dart.fn(() => i, VoidTody namic())));
1084 let it$ = async.StreamIterator.new(async.Stream._check(mkStream( 3)));
1085 try {
1086 while (yield it$.moveNext()) {
1087 let j = it$.current;
1088 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy nc.Future.microtask(dart.fn(() => dart.dsend(ai, '*', j), VoidTodynamic()))));
1089 }
1090 } finally {
1091 yield it$.cancel();
1092 }
1093 }
1094 } finally {
1095 yield it.cancel();
1096 }
1097 return r;
1098 }, dart.dynamic);
1099 }
1100 dart.fn(f, VoidTodynamic());
1101 return dart.dsend(f(), 'then', dart.fn(v => {
1102 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 + 2 + 3 + 4) * (1 + 2)));
1103 }, dynamicTodynamic()));
1104 }, VoidTodynamic()));
1105 }, VoidTovoid()));
1106 };
1107 dart.fn(async_star_test_02_multi.main, VoidTodynamic());
1108 async_star_test_02_multi.id = function(x) {
1109 try {
1110 if (x != null) dart.throw(x);
1111 } catch (e) {
1112 return e;
1113 }
1114
1115 return null;
1116 };
1117 dart.fn(async_star_test_02_multi.id, dynamicTodynamic());
1118 async_star_test_02_multi.expectList = function(stream, list) {
1119 return dart.dsend(dart.dsend(stream, 'toList'), 'then', dart.fn(v => {
1120 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(list));
1121 }, dynamicTodynamic()));
1122 };
1123 dart.fn(async_star_test_02_multi.expectList, dynamicAnddynamicTodynamic());
1124 async_star_test_02_multi.MS = dart.const(new core.Duration({milliseconds: 1})) ;
1125 dart.defineLazy(async_star_test_02_multi, {
1126 get getErrors() {
1127 return async.StreamTransformer.fromHandlers({handleData: dart.fn((data, si nk) => {
1128 src__matcher__expect.fail("Unexpected value");
1129 }, dynamicAndEventSinkTovoid()), handleError: dart.fn((e, s, sink) => {
1130 sink.add(e);
1131 }, ObjectAndStackTraceAndEventSinkTovoid()), handleDone: dart.fn(sink => {
1132 sink.close();
1133 }, EventSinkTovoid())});
1134 },
1135 set getErrors(_) {}
1136 });
1137 async_star_test_02_multi.NotAStream = class NotAStream extends core.Object {
1138 listen(oData, opts) {
1139 let onError = opts && 'onError' in opts ? opts.onError : null;
1140 let onDone = opts && 'onDone' in opts ? opts.onDone : null;
1141 let cancelOnError = opts && 'cancelOnError' in opts ? opts.cancelOnError : null;
1142 src__matcher__expect.fail("Not implementing Stream.");
1143 }
1144 };
1145 dart.setSignature(async_star_test_02_multi.NotAStream, {
1146 methods: () => ({listen: dart.definiteFunctionType(dart.dynamic, [dart.dynam ic], {onError: dart.dynamic, onDone: dart.dynamic, cancelOnError: dart.dynamic}) })
1147 });
1148 const _completer = Symbol('_completer');
1149 async_star_test_02_multi.Sync = class Sync extends core.Object {
1150 new() {
1151 this[_completer] = null;
1152 }
1153 wait(v) {
1154 if (v === void 0) v = null;
1155 if (this[_completer] != null) this[_completer].complete(v);
1156 this[_completer] = async.Completer.new();
1157 return this[_completer].future;
1158 }
1159 release(v) {
1160 if (v === void 0) v = null;
1161 if (this[_completer] != null) {
1162 this[_completer].complete(v);
1163 this[_completer] = null;
1164 }
1165 }
1166 };
1167 dart.setSignature(async_star_test_02_multi.Sync, {
1168 methods: () => ({
1169 wait: dart.definiteFunctionType(async.Future, [], [dart.dynamic]),
1170 release: dart.definiteFunctionType(dart.void, [], [dart.dynamic])
1171 })
1172 });
1173 // Exports:
1174 exports.async_star_test_02_multi = async_star_test_02_multi;
1175 });
OLDNEW
« no previous file with comments | « test/codegen/expect/language/async_star_test_01_multi.js ('k') | test/codegen/expect/language/async_star_test_03_multi.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698