Chromium Code Reviews| 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 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 Loading... | |
| 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: (e, st, sink) => sink.add(["error", e]))).toList(); |
|
nweiz
2013/10/07 20:29:20
Please use a full word rather than "st". Also belo
Bob Nystrom
2013/10/07 20:29:54
e -> error
st -> stackTrace
Here and below.
floitsch
2013/10/10 15:39:57
Done.
floitsch
2013/10/10 15:39:57
Done.
| |
| 56 }), completion(equals([ | 56 }), completion(equals([ |
| 57 ["data", "first"], | 57 ["data", "first"], |
| 58 ["data", "second"], | 58 ["data", "second"], |
| 59 ["error", "third"], | 59 ["error", "third"], |
| 60 ["error", "fourth"], | 60 ["error", "fourth"], |
| 61 ["data", "fifth"] | 61 ["data", "fifth"] |
| 62 ]))); | 62 ]))); |
| 63 | 63 |
| 64 pumpEventQueue().then((_) => pool.close()); | 64 pumpEventQueue().then((_) => pool.close()); |
| 65 }); | 65 }); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 | 104 |
| 105 var controller1 = new StreamController<String>.broadcast(); | 105 var controller1 = new StreamController<String>.broadcast(); |
| 106 pool.add(controller1.stream); | 106 pool.add(controller1.stream); |
| 107 controller1.addError("first"); | 107 controller1.addError("first"); |
| 108 | 108 |
| 109 var controller2 = new StreamController<String>.broadcast(); | 109 var controller2 = new StreamController<String>.broadcast(); |
| 110 pool.add(controller2.stream); | 110 pool.add(controller2.stream); |
| 111 controller2.addError("second"); | 111 controller2.addError("second"); |
| 112 | 112 |
| 113 expect(newFuture(() { | 113 expect(newFuture(() { |
| 114 return pool.stream.transform(new StreamTransformer( | 114 return pool.stream.transform(new StreamTransformer.fromHandlers( |
| 115 handleData: (data, sink) => sink.add(data), | 115 handleData: (data, sink) => sink.add(data), |
| 116 handleError: (error, sink) => sink.add(error))).toList(); | 116 handleError: (error, st, sink) => sink.add(error))).toList(); |
| 117 }), completion(isEmpty)); | 117 }), completion(isEmpty)); |
| 118 | 118 |
| 119 pumpEventQueue().then((_) => pool.close()); | 119 pumpEventQueue().then((_) => pool.close()); |
| 120 }); | 120 }); |
| 121 | 121 |
| 122 test("doesn't buffer inputs from a buffered stream", () { | 122 test("doesn't buffer inputs from a buffered stream", () { |
| 123 var pool = new StreamPool<String>.broadcast(); | 123 var pool = new StreamPool<String>.broadcast(); |
| 124 var controller = new StreamController<String>(); | 124 var controller = new StreamController<String>(); |
| 125 pool.add(controller.stream); | 125 pool.add(controller.stream); |
| 126 controller.add("first"); | 126 controller.add("first"); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 return pumpEventQueue(); | 207 return pumpEventQueue(); |
| 208 }).then((_) { | 208 }).then((_) { |
| 209 pool.remove(broadcastController.stream); | 209 pool.remove(broadcastController.stream); |
| 210 broadcastController.add("fourth"); | 210 broadcastController.add("fourth"); |
| 211 pool.close(); | 211 pool.close(); |
| 212 }), completes); | 212 }), completes); |
| 213 }); | 213 }); |
| 214 }); | 214 }); |
| 215 } | 215 } |
| 216 } | 216 } |
| OLD | NEW |