| 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 "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'event_helper.dart'; | 10 import 'event_helper.dart'; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 })); | 95 })); |
| 96 sentEvents.replay(c); | 96 sentEvents.replay(c); |
| 97 Expect.listEquals(expectedEvents.events, actualEvents.events); | 97 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 98 | 98 |
| 99 // Test transform. | 99 // Test transform. |
| 100 c = new StreamController(sync: true); | 100 c = new StreamController(sync: true); |
| 101 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); | 101 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); |
| 102 expectedEvents = | 102 expectedEvents = |
| 103 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); | 103 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); |
| 104 actualEvents = new Events.capture(c.stream.asBroadcastStream().transform( | 104 actualEvents = new Events.capture(c.stream.asBroadcastStream().transform( |
| 105 new StreamTransformer( | 105 new StreamTransformer.fromHandlers( |
| 106 handleData: (v, s) { s.addError(v); }, | 106 handleData: (v, s) { s.addError(v); }, |
| 107 handleError: (e, s) { s.add(e); }, | 107 handleError: (e, st, s) { s.add(e); }, |
| 108 handleDone: (s) { | 108 handleDone: (s) { |
| 109 s.add("foo"); | 109 s.add("foo"); |
| 110 s.close(); | 110 s.close(); |
| 111 }))); | 111 }))); |
| 112 sentEvents.replay(c); | 112 sentEvents.replay(c); |
| 113 Expect.listEquals(expectedEvents.events, actualEvents.events); | 113 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 114 | 114 |
| 115 // Test multiple filters. | 115 // Test multiple filters. |
| 116 c = new StreamController(sync: true); | 116 c = new StreamController(sync: true); |
| 117 sentEvents = new Events()..add(42) | 117 sentEvents = new Events()..add(42) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 }); | 272 }); |
| 273 sentEvents.replay(c); | 273 sentEvents.replay(c); |
| 274 } | 274 } |
| 275 | 275 |
| 276 // Test transform. | 276 // Test transform. |
| 277 c = new StreamController(sync: true); | 277 c = new StreamController(sync: true); |
| 278 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); | 278 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); |
| 279 expectedEvents = | 279 expectedEvents = |
| 280 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); | 280 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); |
| 281 actualEvents = new Events.capture(c.stream.transform( | 281 actualEvents = new Events.capture(c.stream.transform( |
| 282 new StreamTransformer( | 282 new StreamTransformer.fromHandlers( |
| 283 handleData: (v, s) { s.addError(v); }, | 283 handleData: (v, s) { s.addError(v); }, |
| 284 handleError: (e, s) { s.add(e); }, | 284 handleError: (e, st, s) { s.add(e); }, |
| 285 handleDone: (s) { | 285 handleDone: (s) { |
| 286 s.add("foo"); | 286 s.add("foo"); |
| 287 s.close(); | 287 s.close(); |
| 288 }))); | 288 }))); |
| 289 sentEvents.replay(c); | 289 sentEvents.replay(c); |
| 290 Expect.listEquals(expectedEvents.events, actualEvents.events); | 290 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 291 | 291 |
| 292 // Test multiple filters. | 292 // Test multiple filters. |
| 293 c = new StreamController(sync: true); | 293 c = new StreamController(sync: true); |
| 294 sentEvents = new Events()..add(42) | 294 sentEvents = new Events()..add(42) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 Expect.equals(c.stream, c.stream); | 436 Expect.equals(c.stream, c.stream); |
| 437 } | 437 } |
| 438 | 438 |
| 439 main() { | 439 main() { |
| 440 testMultiController(); | 440 testMultiController(); |
| 441 testSingleController(); | 441 testSingleController(); |
| 442 testExtraMethods(); | 442 testExtraMethods(); |
| 443 testClosed(); | 443 testClosed(); |
| 444 testStreamEquals(); | 444 testStreamEquals(); |
| 445 } | 445 } |
| OLD | NEW |