| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Test the basic StreamController and StreamController.singleSubscription. | 5 // Test the basic StreamController and StreamController.singleSubscription. |
| 6 library stream_controller_test; | 6 library stream_controller_test; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'event_helper.dart'; | 9 import 'event_helper.dart'; |
| 10 | 10 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 for (int i = 0; i < v; i++) l.add(i + 1); | 224 for (int i = 0; i < v; i++) l.add(i + 1); |
| 225 return l; | 225 return l; |
| 226 })); | 226 })); |
| 227 sentEvents.replay(c); | 227 sentEvents.replay(c); |
| 228 Expect.listEquals(expectedEvents.events, actualEvents.events); | 228 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 229 | 229 |
| 230 // pipe is tested asynchronously and therefore not in this file. | 230 // pipe is tested asynchronously and therefore not in this file. |
| 231 c = new StreamController.singleSubscription(); | 231 c = new StreamController.singleSubscription(); |
| 232 var list = <int>[]; | 232 var list = <int>[]; |
| 233 c.pipeInto(new CollectionSink<int>(list)) | 233 c.pipeInto(new CollectionSink<int>(list)) |
| 234 .then(() { Expect.listEquals(<int>[1,2,9,3,9], list); }); | 234 .whenComplete(() { Expect.listEquals(<int>[1,2,9,3,9], list); }); |
| 235 c.add(1); | 235 c.add(1); |
| 236 c.add(2); | 236 c.add(2); |
| 237 c.add(9); | 237 c.add(9); |
| 238 c.add(3); | 238 c.add(3); |
| 239 c.add(9); | 239 c.add(9); |
| 240 c.close(); | 240 c.close(); |
| 241 | 241 |
| 242 // Test transform. | 242 // Test transform. |
| 243 c = new StreamController.singleSubscription(); | 243 c = new StreamController.singleSubscription(); |
| 244 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); | 244 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 actualEvents = new Events.capture(c.distinct((a, b) => a < b)); | 352 actualEvents = new Events.capture(c.distinct((a, b) => a < b)); |
| 353 sentEvents.replay(c); | 353 sentEvents.replay(c); |
| 354 Expect.listEquals(expectedEvents.events, actualEvents.events); | 354 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 355 } | 355 } |
| 356 | 356 |
| 357 main() { | 357 main() { |
| 358 testController(); | 358 testController(); |
| 359 testSingleController(); | 359 testSingleController(); |
| 360 testExtraMethods(); | 360 testExtraMethods(); |
| 361 } | 361 } |
| OLD | NEW |