OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:test/test.dart"; | 6 import "package:unittest/unittest.dart"; |
7 | 7 |
8 main() { | 8 main() { |
9 test("stream iterator basic", () async { | 9 test("stream iterator basic", () async { |
10 var stream = createStream(); | 10 var stream = createStream(); |
11 StreamIterator iterator = new StreamIterator(stream); | 11 StreamIterator iterator = new StreamIterator(stream); |
12 expect(iterator.current, isNull); | 12 expect(iterator.current, isNull); |
13 expect(await iterator.moveNext(), isTrue); | 13 expect(await iterator.moveNext(), isTrue); |
14 expect(iterator.current, 42); | 14 expect(iterator.current, 42); |
15 expect(await iterator.moveNext(), isTrue); | 15 expect(await iterator.moveNext(), isTrue); |
16 expect(iterator.current, 37); | 16 expect(iterator.current, 37); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 /// Create a stream that throws when cancelled. | 87 /// Create a stream that throws when cancelled. |
88 Stream createCancelErrorStream() async* { | 88 Stream createCancelErrorStream() async* { |
89 int i = 0; | 89 int i = 0; |
90 try { | 90 try { |
91 while (true) yield i++; | 91 while (true) yield i++; |
92 } finally { | 92 } finally { |
93 throw "BAD"; | 93 throw "BAD"; |
94 } | 94 } |
95 } | 95 } |
OLD | NEW |