Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: tests/lib_strong/async/stream_iterator_double_cancel_test.dart

Issue 2802973005: Migrate async tests to strong (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:async";
6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart";
8
9 Stream timedStream(int n) {
10 int i = 0;
11 StreamController controller;
12 tick() {
13 if (i >= n) {
14 controller.close();
15 return;
16 }
17 controller.add(i);
18 i++;
19 new Future.delayed(new Duration(milliseconds: 0), tick);
20 }
21 controller = new StreamController(onListen: tick);
22 return controller.stream;
23 }
24
25 void main() {
26 asyncStart();
27 StreamIterator iterator = new StreamIterator(timedStream(10));
28 helper(more) {
29 if (!more) {
30 // Canceling the already closed iterator should not lead to a crash.
31 iterator.cancel();
32 asyncEnd();
33 } else {
34 iterator.moveNext().then(helper);
35 }
36 }
37 iterator.moveNext().then(helper);
38 }
OLDNEW
« no previous file with comments | « tests/lib_strong/async/stream_from_iterable_test.dart ('k') | tests/lib_strong/async/stream_iterator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698