| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 c.close(); | 425 c.close(); |
| 426 }); | 426 }); |
| 427 } | 427 } |
| 428 | 428 |
| 429 testFuture(name, streamValueTransform) { | 429 testFuture(name, streamValueTransform) { |
| 430 test("rethrow-$name-value", () { | 430 test("rethrow-$name-value", () { |
| 431 StreamController c = new StreamController(); | 431 StreamController c = new StreamController(); |
| 432 Future f = streamValueTransform(c.stream, (v) { throw error; }); | 432 Future f = streamValueTransform(c.stream, (v) { throw error; }); |
| 433 f.then((v) { Expect.fail("unreachable"); }, | 433 f.then((v) { Expect.fail("unreachable"); }, |
| 434 onError: expectAsync1((e) { Expect.identical(error, e); })); | 434 onError: expectAsync1((e) { Expect.identical(error, e); })); |
| 435 // Need two values to trigger compare for min/max. | 435 // Need two values to trigger compare for reduce. |
| 436 c.add(0); | 436 c.add(0); |
| 437 c.add(1); | 437 c.add(1); |
| 438 c.close(); | 438 c.close(); |
| 439 }); | 439 }); |
| 440 } | 440 } |
| 441 | 441 |
| 442 testStream("where", (s, act) => s.where(act)); | 442 testStream("where", (s, act) => s.where(act)); |
| 443 testStream("map", (s, act) => s.map(act)); | 443 testStream("map", (s, act) => s.map(act)); |
| 444 testStream("expand", (s, act) => s.expand(act)); | 444 testStream("expand", (s, act) => s.expand(act)); |
| 445 testStream("where", (s, act) => s.where(act)); | 445 testStream("where", (s, act) => s.where(act)); |
| 446 testStreamError("handleError", (s, act) => s.handleError(act)); | 446 testStreamError("handleError", (s, act) => s.handleError(act)); |
| 447 testStreamError("handleTest", (s, act) => s.handleError((v) {}, test: act)); | 447 testStreamError("handleTest", (s, act) => s.handleError((v) {}, test: act)); |
| 448 testFuture("every", (s, act) => s.every(act)); | 448 testFuture("every", (s, act) => s.every(act)); |
| 449 testFuture("any", (s, act) => s.any(act)); | 449 testFuture("any", (s, act) => s.any(act)); |
| 450 testFuture("min", (s, act) => s.min((a, b) => act(b))); | 450 testFuture("reduce", (s, act) => s.reduce((a,b) => act(b))); |
| 451 testFuture("max", (s, act) => s.max((a, b) => act(b))); | |
| 452 testFuture("reduce", (s, act) => s.reduce(0, (a,b) => act(b))); | |
| 453 testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b))); | 451 testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b))); |
| 454 } | 452 } |
| 455 | 453 |
| 456 main() { | 454 main() { |
| 457 testController(); | 455 testController(); |
| 458 testSingleController(); | 456 testSingleController(); |
| 459 testExtraMethods(); | 457 testExtraMethods(); |
| 460 testPause(); | 458 testPause(); |
| 461 testRethrow(); | 459 testRethrow(); |
| 462 } | 460 } |
| OLD | NEW |