OLD | NEW |
1 dart_library.library('language/async_star_regression_fisk_test', null, /* Import
s */[ | 1 dart_library.library('language/async_star_regression_fisk_test', null, /* Import
s */[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'async_helper', | 3 'async_helper', |
4 'expect' | 4 'expect' |
5 ], function load__async_star_regression_fisk_test(exports, dart_sdk, async_helpe
r, expect) { | 5 ], function load__async_star_regression_fisk_test(exports, dart_sdk, async_helpe
r, expect) { |
6 'use strict'; | 6 'use strict'; |
7 const core = dart_sdk.core; | 7 const core = dart_sdk.core; |
8 const async = dart_sdk.async; | 8 const async = dart_sdk.async; |
9 const _interceptors = dart_sdk._interceptors; | 9 const _interceptors = dart_sdk._interceptors; |
10 const dart = dart_sdk.dart; | 10 const dart = dart_sdk.dart; |
11 const dartx = dart_sdk.dartx; | 11 const dartx = dart_sdk.dartx; |
12 const async_helper$ = async_helper.async_helper; | 12 const async_helper$ = async_helper.async_helper; |
13 const expect$ = expect.expect; | 13 const expect$ = expect.expect; |
14 const async_star_regression_fisk_test = Object.create(null); | 14 const async_star_regression_fisk_test = Object.create(null); |
15 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); | 15 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); |
16 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core
.int, [])))(); | 16 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core
.int, [])))(); |
| 17 let VoidToStream = () => (VoidToStream = dart.constFn(dart.definiteFunctionTyp
e(async.Stream, [])))(); |
| 18 let intToFuture = () => (intToFuture = dart.constFn(dart.definiteFunctionType(
async.Future, [core.int])))(); |
17 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); | 19 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
18 let intTodynamic = () => (intTodynamic = dart.constFn(dart.definiteFunctionTyp
e(dart.dynamic, [core.int])))(); | 20 let VoidToFuture = () => (VoidToFuture = dart.constFn(dart.definiteFunctionTyp
e(async.Future, [])))(); |
19 async_star_regression_fisk_test.main = function() { | 21 async_star_regression_fisk_test.main = function() { |
20 let res = []; | 22 let res = []; |
21 function fisk() { | 23 function fisk() { |
22 return dart.asyncStar(function*(stream) { | 24 return dart.asyncStar(function*(stream) { |
23 res[dartx.add]("+fisk"); | 25 res[dartx.add]("+fisk"); |
24 try { | 26 try { |
25 for (let i = 0; i < 2; i++) { | 27 for (let i = 0; i < 2; i++) { |
26 if (stream.add(yield async.Future.microtask(dart.fn(() => i, VoidToi
nt())))) return; | 28 if (stream.add(yield async.Future.microtask(dart.fn(() => i, VoidToi
nt())))) return; |
27 yield; | 29 yield; |
28 } | 30 } |
29 } finally { | 31 } finally { |
30 res[dartx.add]("-fisk"); | 32 res[dartx.add]("-fisk"); |
31 } | 33 } |
32 }, dart.dynamic); | 34 }, dart.dynamic); |
33 } | 35 } |
34 dart.fn(fisk, VoidTodynamic()); | 36 dart.fn(fisk, VoidToStream()); |
35 function fugl(count) { | 37 function fugl(count) { |
36 return dart.async(function*(count) { | 38 return dart.async(function*(count) { |
37 res[dartx.add](dart.str`fisk ${count}`); | 39 res[dartx.add](dart.str`fisk ${count}`); |
38 try { | 40 try { |
39 let it = async.StreamIterator.new(async.Stream._check(dart.dsend(fisk(
), 'take', count))); | 41 let it = async.StreamIterator.new(fisk().take(count)); |
40 try { | 42 try { |
41 while (yield it.moveNext()) { | 43 while (yield it.moveNext()) { |
42 let i = it.current; | 44 let i = it.current; |
43 core.int._check(i); | 45 core.int._check(i); |
44 res[dartx.add](i); | 46 res[dartx.add](i); |
45 } | 47 } |
46 } finally { | 48 } finally { |
47 yield it.cancel(); | 49 yield it.cancel(); |
48 } | 50 } |
49 } finally { | 51 } finally { |
50 res[dartx.add]("done"); | 52 res[dartx.add]("done"); |
51 } | 53 } |
52 }, dart.dynamic, count); | 54 }, dart.dynamic, count); |
53 } | 55 } |
54 dart.fn(fugl, intTodynamic()); | 56 dart.fn(fugl, intToFuture()); |
55 async_helper$.asyncStart(); | 57 async_helper$.asyncStart(); |
56 dart.dsend(dart.dsend(dart.dsend(fugl(3), 'whenComplete', dart.fn(() => fugl
(2), VoidTodynamic())), 'whenComplete', dart.fn(() => fugl(1), VoidTodynamic()))
, 'whenComplete', dart.fn(() => { | 58 fugl(3).whenComplete(dart.fn(() => fugl(2), VoidToFuture())).whenComplete(da
rt.fn(() => fugl(1), VoidToFuture())).whenComplete(dart.fn(() => { |
57 expect$.Expect.listEquals(JSArrayOfObject().of(["fisk 3", "+fisk", 0, 1, "
-fisk", "done", "fisk 2", "+fisk", 0, 1, "-fisk", "done", "fisk 1", "+fisk", 0,
"-fisk", "done"]), res); | 59 expect$.Expect.listEquals(JSArrayOfObject().of(["fisk 3", "+fisk", 0, 1, "
-fisk", "done", "fisk 2", "+fisk", 0, 1, "-fisk", "done", "fisk 1", "+fisk", 0,
"-fisk", "done"]), res); |
58 async_helper$.asyncEnd(); | 60 async_helper$.asyncEnd(); |
59 }, VoidTodynamic())); | 61 }, VoidTodynamic())); |
60 }; | 62 }; |
61 dart.fn(async_star_regression_fisk_test.main, VoidTodynamic()); | 63 dart.fn(async_star_regression_fisk_test.main, VoidTodynamic()); |
62 // Exports: | 64 // Exports: |
63 exports.async_star_regression_fisk_test = async_star_regression_fisk_test; | 65 exports.async_star_regression_fisk_test = async_star_regression_fisk_test; |
64 }); | 66 }); |
OLD | NEW |