| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "dart:async"; | 5 import "dart:async"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 | 8 |
| 9 bool cancelled; | 9 bool cancelled; |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 for (int j = 0; j < 10; j++) { | 39 for (int j = 0; j < 10; j++) { |
| 40 if (j == 5) continue outer; | 40 if (j == 5) continue outer; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 } finally { | 44 } finally { |
| 45 Expect.isTrue(cancelled); | 45 Expect.isTrue(cancelled); |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 | 48 |
| 49 main() async { | 49 test() async { |
| 50 await test1(); | 50 await test1(); |
| 51 await test2(); | 51 await test2(); |
| 52 } |
| 52 | 53 |
| 54 main() async { |
| 55 asyncStart(); |
| 56 test().then((_) { |
| 57 asyncEnd(); |
| 58 }); |
| 53 } | 59 } |
| 54 | 60 |
| 55 | 61 |
| 56 // Create a stream that produces numbers [1, 2, ... ] | 62 // Create a stream that produces numbers [1, 2, ... ] |
| 57 StreamController infiniteStreamController() { | 63 StreamController infiniteStreamController() { |
| 58 StreamController controller; | 64 StreamController controller; |
| 59 Timer timer; | 65 Timer timer; |
| 60 int counter = 0; | 66 int counter = 0; |
| 61 | 67 |
| 62 void tick(_) { | 68 void tick(_) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 79 onListen: startTimer, | 85 onListen: startTimer, |
| 80 onPause: stopTimer, | 86 onPause: stopTimer, |
| 81 onResume: startTimer, | 87 onResume: startTimer, |
| 82 onCancel: () { | 88 onCancel: () { |
| 83 cancelled = true; | 89 cancelled = true; |
| 84 stopTimer(); | 90 stopTimer(); |
| 85 }); | 91 }); |
| 86 | 92 |
| 87 return controller; | 93 return controller; |
| 88 } | 94 } |
| OLD | NEW |