| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 Stream<int> foo1() async* { | 9 Stream<int> foo1() async* { |
| 10 yield 1; | 10 yield 1; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 Stream<int> foo4() async* { | 47 Stream<int> foo4() async* { |
| 48 int i = 0; | 48 int i = 0; |
| 49 try { | 49 try { |
| 50 while (true) { | 50 while (true) { |
| 51 yield i; | 51 yield i; |
| 52 i++; | 52 i++; |
| 53 } | 53 } |
| 54 } finally { | 54 } finally { |
| 55 // Canceling the stream-subscription should run the finalizer. | 55 // Canceling the stream-subscription should run the finalizer. |
| 56 finalized.complete(true); | 56 finalized.complete(true); |
| 57 return; |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| 60 test() async { | 61 test() async { |
| 61 Expect.listEquals([1, 20], await (foo1().toList())); | 62 Expect.listEquals([1, 20], await (foo1().toList())); |
| 62 Expect.listEquals([0, 1, 2, 3], await (foo2().take(4).toList())); | 63 Expect.listEquals([0, 1, 2, 3], await (foo2().take(4).toList())); |
| 63 Expect.listEquals([null, -1, 0, 1, 2, 3, 0, 1, 2, 3], | 64 Expect.listEquals([null, -1, 0, 1, 2, 3, 0, 1, 2, 3], |
| 64 await (foo3(4).take(10).toList())); | 65 await (foo3(4).take(10).toList())); |
| 65 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], | 66 Expect.listEquals([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 66 await (foo4().take(10).toList())); | 67 await (foo4().take(10).toList())); |
| 67 Expect.isTrue(await (finalized.future)); | 68 Expect.isTrue(await (finalized.future)); |
| 68 } | 69 } |
| 69 | 70 |
| 70 main () { | 71 main () { |
| 71 asyncStart(); | 72 asyncStart(); |
| 72 test().then((_) { | 73 test().then((_) { |
| 73 asyncEnd(); | 74 asyncEnd(); |
| 74 }); | 75 }); |
| 75 } | 76 } |
| OLD | NEW |