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

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

Issue 903433002: Change timer delay to 0 to make jsshell happy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 timedStream(int n) { 9 Stream timedStream(int n) {
10 int i = 0; 10 int i = 0;
11 StreamController controller; 11 StreamController controller;
12 tick() { 12 tick() {
13 if (i >= n) { 13 if (i >= n) {
14 controller.close(); 14 controller.close();
15 return; 15 return;
16 } 16 }
17 controller.add(i); 17 controller.add(i);
18 i++; 18 i++;
19 new Future.delayed(new Duration(milliseconds: 10), tick); 19 new Future.delayed(new Duration(milliseconds: 0), tick);
20 } 20 }
21 controller = new StreamController(onListen: tick); 21 controller = new StreamController(onListen: tick);
22 return controller.stream; 22 return controller.stream;
23 } 23 }
24 24
25 void main() { 25 void main() {
26 asyncStart(); 26 asyncStart();
27 StreamIterator iterator = new StreamIterator(timedStream(10)); 27 StreamIterator iterator = new StreamIterator(timedStream(10));
28 helper(more) { 28 helper(more) {
29 if (!more) { 29 if (!more) {
30 // Canceling the already closed iterator should not lead to a crash. 30 // Canceling the already closed iterator should not lead to a crash.
31 iterator.cancel(); 31 iterator.cancel();
32 asyncEnd(); 32 asyncEnd();
33 } else { 33 } else {
34 iterator.moveNext().then(helper); 34 iterator.moveNext().then(helper);
35 } 35 }
36 } 36 }
37 iterator.moveNext().then(helper); 37 iterator.moveNext().then(helper);
38 } 38 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698