OLD | NEW |
1 dart_library.library('language/async_star_cancel_while_paused_test', null, /* Im
ports */[ | 1 dart_library.library('language/async_star_cancel_while_paused_test', null, /* Im
ports */[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'async_helper', | 3 'async_helper', |
4 'expect' | 4 'expect' |
5 ], function load__async_star_cancel_while_paused_test(exports, dart_sdk, async_h
elper, expect) { | 5 ], function load__async_star_cancel_while_paused_test(exports, dart_sdk, async_h
elper, 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 _interceptors = dart_sdk._interceptors; | 9 const _interceptors = dart_sdk._interceptors; |
9 const async = dart_sdk.async; | |
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_cancel_while_paused_test = Object.create(null); | 14 const async_star_cancel_while_paused_test = Object.create(null); |
| 15 let StreamOfint = () => (StreamOfint = dart.constFn(async.Stream$(core.int)))(
); |
| 16 let intTovoid = () => (intTovoid = dart.constFn(dart.functionType(dart.void, [
core.int])))(); |
15 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); | 17 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); |
| 18 let VoidToStreamOfint = () => (VoidToStreamOfint = dart.constFn(dart.definiteF
unctionType(StreamOfint(), [])))(); |
16 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); | 19 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
17 let VoidToFuture = () => (VoidToFuture = dart.constFn(dart.definiteFunctionTyp
e(async.Future, [])))(); | 20 let VoidToFuture = () => (VoidToFuture = dart.constFn(dart.definiteFunctionTyp
e(async.Future, [])))(); |
18 async_star_cancel_while_paused_test.main = function() { | 21 async_star_cancel_while_paused_test.main = function() { |
19 let list = []; | 22 let list = []; |
20 let sync = new async_star_cancel_while_paused_test.Sync(); | 23 let sync = new async_star_cancel_while_paused_test.Sync(); |
21 function f() { | 24 function f() { |
22 return dart.asyncStar(function*(stream) { | 25 return dart.asyncStar(function*(stream) { |
23 list[dartx.add]("*1"); | 26 list[dartx.add]("*1"); |
24 if (stream.add(1)) return; | 27 if (stream.add(1)) return; |
25 yield; | 28 yield; |
26 yield sync.wait(); | 29 yield sync.wait(); |
27 sync.release(); | 30 sync.release(); |
28 list[dartx.add]("*2"); | 31 list[dartx.add]("*2"); |
29 if (stream.add(2)) return; | 32 if (stream.add(2)) return; |
30 yield; | 33 yield; |
31 list[dartx.add]("*3"); | 34 list[dartx.add]("*3"); |
32 }, dart.dynamic); | 35 }, core.int); |
33 } | 36 } |
34 dart.fn(f, VoidTodynamic()); | 37 dart.fn(f, VoidToStreamOfint()); |
35 ; | 38 ; |
36 let stream = f(); | 39 let stream = f(); |
37 let sub = dart.dsend(stream, 'listen', dart.bind(list, dartx.add)); | 40 let sub = stream.listen(intTovoid()._check(dart.bind(list, dartx.add))); |
38 async_helper$.asyncStart(); | 41 async_helper$.asyncStart(); |
39 return sync.wait().whenComplete(dart.fn(() => { | 42 return sync.wait().whenComplete(dart.fn(() => { |
40 expect$.Expect.listEquals(list, JSArrayOfObject().of(["*1", 1])); | 43 expect$.Expect.listEquals(list, JSArrayOfObject().of(["*1", 1])); |
41 dart.dsend(sub, 'pause'); | 44 sub.pause(); |
42 return sync.wait(); | 45 return sync.wait(); |
43 }, VoidToFuture())).whenComplete(dart.fn(() => { | 46 }, VoidToFuture())).whenComplete(dart.fn(() => { |
44 expect$.Expect.listEquals(list, JSArrayOfObject().of(["*1", 1, "*2"])); | 47 expect$.Expect.listEquals(list, JSArrayOfObject().of(["*1", 1, "*2"])); |
45 dart.dsend(sub, 'cancel'); | 48 sub.cancel(); |
46 async.Future.delayed(new core.Duration({milliseconds: 200}), dart.fn(() =>
{ | 49 async.Future.delayed(new core.Duration({milliseconds: 200}), dart.fn(() =>
{ |
47 expect$.Expect.listEquals(list, JSArrayOfObject().of(["*1", 1, "*2"])); | 50 expect$.Expect.listEquals(list, JSArrayOfObject().of(["*1", 1, "*2"])); |
48 async_helper$.asyncEnd(); | 51 async_helper$.asyncEnd(); |
49 }, VoidTodynamic())); | 52 }, VoidTodynamic())); |
50 }, VoidTodynamic())); | 53 }, VoidTodynamic())); |
51 }; | 54 }; |
52 dart.fn(async_star_cancel_while_paused_test.main, VoidTodynamic()); | 55 dart.fn(async_star_cancel_while_paused_test.main, VoidTodynamic()); |
53 const _completer = Symbol('_completer'); | 56 const _completer = Symbol('_completer'); |
54 async_star_cancel_while_paused_test.Sync = class Sync extends core.Object { | 57 async_star_cancel_while_paused_test.Sync = class Sync extends core.Object { |
55 new() { | 58 new() { |
(...skipping 15 matching lines...) Expand all Loading... |
71 }; | 74 }; |
72 dart.setSignature(async_star_cancel_while_paused_test.Sync, { | 75 dart.setSignature(async_star_cancel_while_paused_test.Sync, { |
73 methods: () => ({ | 76 methods: () => ({ |
74 wait: dart.definiteFunctionType(async.Future, [], [dart.dynamic]), | 77 wait: dart.definiteFunctionType(async.Future, [], [dart.dynamic]), |
75 release: dart.definiteFunctionType(dart.void, [], [dart.dynamic]) | 78 release: dart.definiteFunctionType(dart.void, [], [dart.dynamic]) |
76 }) | 79 }) |
77 }); | 80 }); |
78 // Exports: | 81 // Exports: |
79 exports.async_star_cancel_while_paused_test = async_star_cancel_while_paused_t
est; | 82 exports.async_star_cancel_while_paused_test = async_star_cancel_while_paused_t
est; |
80 }); | 83 }); |
OLD | NEW |