| 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_async_test; |    6 library stream_controller_async_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 'dart:isolate'; |   10 import 'dart:isolate'; | 
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  405   testStream("where", (s, act) => s.where(act)); |  405   testStream("where", (s, act) => s.where(act)); | 
|  406   testStreamError("handleError", (s, act) => s.handleError(act)); |  406   testStreamError("handleError", (s, act) => s.handleError(act)); | 
|  407   testStreamError("handleTest", (s, act) => s.handleError((v) {}, test: act)); |  407   testStreamError("handleTest", (s, act) => s.handleError((v) {}, test: act)); | 
|  408   testFuture("forEach", (s, act) => s.forEach(act)); |  408   testFuture("forEach", (s, act) => s.forEach(act)); | 
|  409   testFuture("every", (s, act) => s.every(act)); |  409   testFuture("every", (s, act) => s.every(act)); | 
|  410   testFuture("any", (s, act) => s.any(act)); |  410   testFuture("any", (s, act) => s.any(act)); | 
|  411   testFuture("reduce", (s, act) => s.reduce((a,b) => act(b))); |  411   testFuture("reduce", (s, act) => s.reduce((a,b) => act(b))); | 
|  412   testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b))); |  412   testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b))); | 
|  413 } |  413 } | 
|  414  |  414  | 
 |  415 void testMultiplex() { | 
 |  416   test("multiplex-basic", () { | 
 |  417     StreamController<int> c = new StreamController.multiplex( | 
 |  418       onListen: expectAsync0(() {}), | 
 |  419       onCancel: expectAsync0(() {}) | 
 |  420     ); | 
 |  421     Stream<int> s = c.stream; | 
 |  422     s.listen(expectAsync1((x) { expect(x, equals(42)); })); | 
 |  423     c.add(42); | 
 |  424     c.close(); | 
 |  425   }); | 
 |  426  | 
 |  427   test("multiplex-listen-twice", () { | 
 |  428     StreamController<int> c = new StreamController.multiplex( | 
 |  429       onListen: expectAsync0(() {}), | 
 |  430       onCancel: expectAsync0(() {}) | 
 |  431     ); | 
 |  432     c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }, count: 2)); | 
 |  433     c.add(42); | 
 |  434     c.stream.listen(expectAsync1((x) { expect(x, equals(42)); })); | 
 |  435     c.add(42); | 
 |  436     c.close(); | 
 |  437   }); | 
 |  438  | 
 |  439   test("multiplex-listen-twice-non-overlap", () { | 
 |  440     StreamController<int> c = new StreamController.multiplex( | 
 |  441       onListen: expectAsync0(() {}, count: 2), | 
 |  442       onCancel: expectAsync0(() {}, count: 2) | 
 |  443     ); | 
 |  444     var sub = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); })); | 
 |  445     c.add(42); | 
 |  446     sub.cancel(); | 
 |  447     c.stream.listen(expectAsync1((x) { expect(x, equals(42)); })); | 
 |  448     c.add(42); | 
 |  449     c.close(); | 
 |  450   }); | 
 |  451  | 
 |  452   test("multiplex-individual-pause", () { | 
 |  453     StreamController<int> c = new StreamController.multiplex( | 
 |  454       onListen: expectAsync0(() {}), | 
 |  455       onCancel: expectAsync0(() {}) | 
 |  456     ); | 
 |  457     var sub1 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); })); | 
 |  458     var sub2 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); }, | 
 |  459                                             count: 3)); | 
 |  460     c.add(42); | 
 |  461     sub1.pause(); | 
 |  462     c.add(42); | 
 |  463     sub1.cancel(); | 
 |  464     var sub3 = c.stream.listen(expectAsync1((x) { expect(x, equals(42)); })); | 
 |  465     c.add(42); | 
 |  466     c.close(); | 
 |  467   }); | 
 |  468 } | 
 |  469  | 
|  415 main() { |  470 main() { | 
|  416   testController(); |  471   testController(); | 
|  417   testSingleController(); |  472   testSingleController(); | 
|  418   testExtraMethods(); |  473   testExtraMethods(); | 
|  419   testPause(); |  474   testPause(); | 
|  420   testRethrow(); |  475   testRethrow(); | 
 |  476   testMultiplex(); | 
|  421 } |  477 } | 
| OLD | NEW |