Chromium Code Reviews| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 })); | 86 })); |
| 87 sentEvents.replay(c); | 87 sentEvents.replay(c); |
| 88 Expect.listEquals(expectedEvents.events, actualEvents.events); | 88 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 89 | 89 |
| 90 // Test transform. | 90 // Test transform. |
| 91 c = new StreamController.broadcast(); | 91 c = new StreamController.broadcast(); |
| 92 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); | 92 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); |
| 93 expectedEvents = | 93 expectedEvents = |
| 94 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); | 94 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); |
| 95 actualEvents = new Events.capture(c.stream.transform( | 95 actualEvents = new Events.capture(c.stream.transform( |
| 96 new StreamTransformer.from( | 96 new StreamTransformer( |
| 97 onData: (v, s) { s.signalError(new AsyncError(v)); }, | 97 handleData: (v, s) { s.signalError(new AsyncError(v)); }, |
| 98 onError: (e, s) { s.add(e.error); }, | 98 handleError: (e, s) { s.add(e.error); }, |
|
floitsch
2013/01/29 13:37:04
The e.error is not necessary anymore. Is it?
Lasse Reichstein Nielsen
2013/01/29 14:04:14
In this case, I convert the thrown value to a data
| |
| 99 onDone: (s) { | 99 handleDone: (s) { |
| 100 s.add("foo"); | 100 s.add("foo"); |
| 101 s.close(); | 101 s.close(); |
| 102 }))); | 102 }))); |
| 103 sentEvents.replay(c); | 103 sentEvents.replay(c); |
| 104 Expect.listEquals(expectedEvents.events, actualEvents.events); | 104 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 105 | 105 |
| 106 // Test multiple filters. | 106 // Test multiple filters. |
| 107 c = new StreamController.broadcast(); | 107 c = new StreamController.broadcast(); |
| 108 sentEvents = new Events()..add(42) | 108 sentEvents = new Events()..add(42) |
| 109 ..add("snugglefluffy") | 109 ..add("snugglefluffy") |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 }); | 275 }); |
| 276 sentEvents.replay(c); | 276 sentEvents.replay(c); |
| 277 } | 277 } |
| 278 | 278 |
| 279 // Test transform. | 279 // Test transform. |
| 280 c = new StreamController(); | 280 c = new StreamController(); |
| 281 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); | 281 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); |
| 282 expectedEvents = | 282 expectedEvents = |
| 283 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); | 283 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); |
| 284 actualEvents = new Events.capture(c.stream.transform( | 284 actualEvents = new Events.capture(c.stream.transform( |
| 285 new StreamTransformer.from( | 285 new StreamTransformer( |
| 286 onData: (v, s) { s.signalError(new AsyncError(v)); }, | 286 handleData: (v, s) { s.signalError(new AsyncError(v)); }, |
| 287 onError: (e, s) { s.add(e.error); }, | 287 handleError: (e, s) { s.add(e.error); }, |
| 288 onDone: (s) { | 288 handleDone: (s) { |
| 289 s.add("foo"); | 289 s.add("foo"); |
| 290 s.close(); | 290 s.close(); |
| 291 }))); | 291 }))); |
| 292 sentEvents.replay(c); | 292 sentEvents.replay(c); |
| 293 Expect.listEquals(expectedEvents.events, actualEvents.events); | 293 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 294 | 294 |
| 295 // Test multiple filters. | 295 // Test multiple filters. |
| 296 c = new StreamController(); | 296 c = new StreamController(); |
| 297 sentEvents = new Events()..add(42) | 297 sentEvents = new Events()..add(42) |
| 298 ..add("snugglefluffy") | 298 ..add("snugglefluffy") |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 actualEvents = new Events.capture(c.stream.distinct((a, b) => a < b)); | 390 actualEvents = new Events.capture(c.stream.distinct((a, b) => a < b)); |
| 391 sentEvents.replay(c); | 391 sentEvents.replay(c); |
| 392 Expect.listEquals(expectedEvents.events, actualEvents.events); | 392 Expect.listEquals(expectedEvents.events, actualEvents.events); |
| 393 } | 393 } |
| 394 | 394 |
| 395 main() { | 395 main() { |
| 396 testMultiController(); | 396 testMultiController(); |
| 397 testSingleController(); | 397 testSingleController(); |
| 398 testExtraMethods(); | 398 testExtraMethods(); |
| 399 } | 399 } |
| OLD | NEW |