OLD | NEW |
1 dart_library.library('language/async_star_await_pauses_test', null, /* Imports *
/[ | 1 dart_library.library('language/async_star_await_pauses_test', null, /* Imports *
/[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'async_helper', | 3 'async_helper', |
4 'expect' | 4 'expect' |
5 ], function load__async_star_await_pauses_test(exports, dart_sdk, async_helper,
expect) { | 5 ], function load__async_star_await_pauses_test(exports, dart_sdk, async_helper,
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 dart = dart_sdk.dart; | 9 const dart = dart_sdk.dart; |
10 const dartx = dart_sdk.dartx; | 10 const dartx = dart_sdk.dartx; |
11 const async_helper$ = async_helper.async_helper; | 11 const async_helper$ = async_helper.async_helper; |
12 const expect$ = expect.expect; | 12 const expect$ = expect.expect; |
13 const async_star_await_pauses_test = Object.create(null); | 13 const async_star_await_pauses_test = Object.create(null); |
| 14 let FutureOfint = () => (FutureOfint = dart.constFn(async.Future$(core.int)))(
); |
14 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); | 15 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
15 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); | 16 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
16 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); | 17 let dynamicToFutureOfint = () => (dynamicToFutureOfint = dart.constFn(dart.def
initeFunctionType(FutureOfint(), [dart.dynamic])))(); |
| 18 let intTodynamic = () => (intTodynamic = dart.constFn(dart.definiteFunctionTyp
e(dart.dynamic, [core.int])))(); |
17 async_star_await_pauses_test.main = function() { | 19 async_star_await_pauses_test.main = function() { |
18 let sc = null; | 20 let sc = null; |
19 let i = 0; | 21 let i = 0; |
20 function send() { | 22 function send() { |
21 if (i == 5) { | 23 if (i == 5) { |
22 dart.dsend(sc, 'close'); | 24 dart.dsend(sc, 'close'); |
23 } else { | 25 } else { |
24 dart.dsend(sc, 'add', i++); | 26 dart.dsend(sc, 'add', i++); |
25 } | 27 } |
26 } | 28 } |
27 dart.fn(send, VoidTovoid()); | 29 dart.fn(send, VoidTovoid()); |
28 sc = async.StreamController.new({onListen: send, onResume: send}); | 30 sc = async.StreamController.new({onListen: send, onResume: send}); |
29 function f(s) { | 31 function f(s) { |
30 return dart.async(function*(s) { | 32 return dart.async(function*(s) { |
31 let r = 0; | 33 let r = 0; |
32 let it = async.StreamIterator.new(async.Stream._check(s)); | 34 let it = async.StreamIterator.new(async.Stream._check(s)); |
33 try { | 35 try { |
34 while (yield it.moveNext()) { | 36 while (yield it.moveNext()) { |
35 let i = it.current; | 37 let i = it.current; |
36 r = dart.notNull(r) + dart.notNull(core.int._check(yield async.Futur
e.delayed(new core.Duration({milliseconds: 10}), dart.fn(() => i, VoidTodynamic(
))))); | 38 r = dart.notNull(r) + dart.notNull(core.int._check(yield async.Futur
e.delayed(new core.Duration({milliseconds: 10}), dart.fn(() => i, VoidTodynamic(
))))); |
37 } | 39 } |
38 } finally { | 40 } finally { |
39 yield it.cancel(); | 41 yield it.cancel(); |
40 } | 42 } |
41 return r; | 43 return r; |
42 }, dart.dynamic, s); | 44 }, core.int, s); |
43 } | 45 } |
44 dart.fn(f, dynamicTodynamic()); | 46 dart.fn(f, dynamicToFutureOfint()); |
45 async_helper$.asyncStart(); | 47 async_helper$.asyncStart(); |
46 dart.dsend(f(dart.dload(sc, 'stream')), 'then', dart.fn(v => { | 48 f(dart.dload(sc, 'stream')).then(dart.dynamic)(dart.fn(v => { |
47 expect$.Expect.equals(10, v); | 49 expect$.Expect.equals(10, v); |
48 async_helper$.asyncEnd(); | 50 async_helper$.asyncEnd(); |
49 }, dynamicTodynamic())); | 51 }, intTodynamic())); |
50 }; | 52 }; |
51 dart.fn(async_star_await_pauses_test.main, VoidTodynamic()); | 53 dart.fn(async_star_await_pauses_test.main, VoidTodynamic()); |
52 // Exports: | 54 // Exports: |
53 exports.async_star_await_pauses_test = async_star_await_pauses_test; | 55 exports.async_star_await_pauses_test = async_star_await_pauses_test; |
54 }); | 56 }); |
OLD | NEW |