| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 sentEvents = new Events() | 385 sentEvents = new Events() |
| 386 ..add(5)..add(6)..add(4)..add(6)..add(8)..add(3)..add(4)..add(1)..close(); | 386 ..add(5)..add(6)..add(4)..add(6)..add(8)..add(3)..add(4)..add(1)..close(); |
| 387 expectedEvents = new Events() | 387 expectedEvents = new Events() |
| 388 ..add(5)..add(4)..add(3)..add(1)..close(); | 388 ..add(5)..add(4)..add(3)..add(1)..close(); |
| 389 // Use 'distinct' as a filter with access to the previously emitted event. | 389 // Use 'distinct' as a filter with access to the previously emitted event. |
| 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 testClosed() { |
| 396 for (StreamController c in [new StreamController(), |
| 397 new StreamController.broadcast()]) { |
| 398 Expect.isFalse(c.isClosed); |
| 399 c.add(42); |
| 400 Expect.isFalse(c.isClosed); |
| 401 c.signalError("bad"); |
| 402 Expect.isFalse(c.isClosed); |
| 403 c.close(); |
| 404 Expect.isTrue(c.isClosed); |
| 405 } |
| 406 } |
| 407 |
| 395 main() { | 408 main() { |
| 396 testMultiController(); | 409 testMultiController(); |
| 397 testSingleController(); | 410 testSingleController(); |
| 398 testExtraMethods(); | 411 testExtraMethods(); |
| 412 testClosed(); |
| 399 } | 413 } |
| OLD | NEW |