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

Side by Side Diff: pkg/barback/test/stream_pool_test.dart

Issue 25354003: Redo StreamTransformers so they work with Stack traces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 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 | pkg/http_server/lib/src/http_body_impl.dart » ('j') | 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) 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 library barback.test.stream_pool_test; 5 library barback.test.stream_pool_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/src/stream_pool.dart'; 9 import 'package:barback/src/stream_pool.dart';
10 import 'package:barback/src/utils.dart'; 10 import 'package:barback/src/utils.dart';
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 controller1.add("first"); 43 controller1.add("first");
44 44
45 var controller2 = new StreamController<String>(); 45 var controller2 = new StreamController<String>();
46 pool.add(controller2.stream); 46 pool.add(controller2.stream);
47 controller2.add("second"); 47 controller2.add("second");
48 controller1.addError("third"); 48 controller1.addError("third");
49 controller2.addError("fourth"); 49 controller2.addError("fourth");
50 controller1.add("fifth"); 50 controller1.add("fifth");
51 51
52 expect(newFuture(() { 52 expect(newFuture(() {
53 return pool.stream.transform(new StreamTransformer( 53 return pool.stream.transform(new StreamTransformer.fromHandlers(
54 handleData: (data, sink) => sink.add(["data", data]), 54 handleData: (data, sink) => sink.add(["data", data]),
55 handleError: (error, sink) => sink.add(["error", error]))).toList(); 55 handleError: (error, stackTrace, sink) {
56 sink.add(["error", error]);
57 })).toList();
56 }), completion(equals([ 58 }), completion(equals([
57 ["data", "first"], 59 ["data", "first"],
58 ["data", "second"], 60 ["data", "second"],
59 ["error", "third"], 61 ["error", "third"],
60 ["error", "fourth"], 62 ["error", "fourth"],
61 ["data", "fifth"] 63 ["data", "fifth"]
62 ]))); 64 ])));
63 65
64 pumpEventQueue().then((_) => pool.close()); 66 pumpEventQueue().then((_) => pool.close());
65 }); 67 });
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 106
105 var controller1 = new StreamController<String>.broadcast(); 107 var controller1 = new StreamController<String>.broadcast();
106 pool.add(controller1.stream); 108 pool.add(controller1.stream);
107 controller1.addError("first"); 109 controller1.addError("first");
108 110
109 var controller2 = new StreamController<String>.broadcast(); 111 var controller2 = new StreamController<String>.broadcast();
110 pool.add(controller2.stream); 112 pool.add(controller2.stream);
111 controller2.addError("second"); 113 controller2.addError("second");
112 114
113 expect(newFuture(() { 115 expect(newFuture(() {
114 return pool.stream.transform(new StreamTransformer( 116 return pool.stream.transform(new StreamTransformer.fromHandlers(
115 handleData: (data, sink) => sink.add(data), 117 handleData: (data, sink) => sink.add(data),
116 handleError: (error, sink) => sink.add(error))).toList(); 118 handleError: (error, stackTrace, sink) { sink.add(error); }))
119 .toList();
117 }), completion(isEmpty)); 120 }), completion(isEmpty));
118 121
119 pumpEventQueue().then((_) => pool.close()); 122 pumpEventQueue().then((_) => pool.close());
120 }); 123 });
121 124
122 test("doesn't buffer inputs from a buffered stream", () { 125 test("doesn't buffer inputs from a buffered stream", () {
123 var pool = new StreamPool<String>.broadcast(); 126 var pool = new StreamPool<String>.broadcast();
124 var controller = new StreamController<String>(); 127 var controller = new StreamController<String>();
125 pool.add(controller.stream); 128 pool.add(controller.stream);
126 controller.add("first"); 129 controller.add("first");
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return pumpEventQueue(); 210 return pumpEventQueue();
208 }).then((_) { 211 }).then((_) {
209 pool.remove(broadcastController.stream); 212 pool.remove(broadcastController.stream);
210 broadcastController.add("fourth"); 213 broadcastController.add("fourth");
211 pool.close(); 214 pool.close();
212 }), completes); 215 }), completes);
213 }); 216 });
214 }); 217 });
215 } 218 }
216 } 219 }
OLDNEW
« no previous file with comments | « no previous file | pkg/http_server/lib/src/http_body_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698