| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library future_test; | 5 library future_test; |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 asyncStart(); | 610 asyncStart(); |
| 611 | 611 |
| 612 future.then((v) => new Future.error("Fehler")) | 612 future.then((v) => new Future.error("Fehler")) |
| 613 .then((v) { Expect.fail("unreachable!"); }, onError: (error) { | 613 .then((v) { Expect.fail("unreachable!"); }, onError: (error) { |
| 614 Expect.equals("Fehler", error); | 614 Expect.equals("Fehler", error); |
| 615 asyncEnd(); | 615 asyncEnd(); |
| 616 }); | 616 }); |
| 617 completer.complete(21); | 617 completer.complete(21); |
| 618 } | 618 } |
| 619 | 619 |
| 620 void testChainedFutureCycle() { |
| 621 asyncStart(); |
| 622 var completer = new Completer(); |
| 623 var future, future2; |
| 624 future = completer.future.then((_) => future2); |
| 625 future2 = completer.future.then((_) => future); |
| 626 completer.complete(42); |
| 627 int ctr = 2; |
| 628 void receiveError(e) { |
| 629 Expect.isTrue(e is StateError); |
| 630 if (--ctr == 0) asyncEnd(); |
| 631 } |
| 632 future.catchError(receiveError); |
| 633 future.catchError(receiveError); |
| 634 } |
| 635 |
| 620 main() { | 636 main() { |
| 621 testValue(); | 637 testValue(); |
| 622 testSync(); | 638 testSync(); |
| 623 testNeverComplete(); | 639 testNeverComplete(); |
| 624 | 640 |
| 625 testComplete(); | 641 testComplete(); |
| 626 testCompleteWithSuccessHandlerBeforeComplete(); | 642 testCompleteWithSuccessHandlerBeforeComplete(); |
| 627 testCompleteWithSuccessHandlerAfterComplete(); | 643 testCompleteWithSuccessHandlerAfterComplete(); |
| 628 testCompleteManySuccessHandlers(); | 644 testCompleteManySuccessHandlers(); |
| 629 testCompleteWithError(); | 645 testCompleteWithError(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 651 testFutureWhenErrorFutureError(); | 667 testFutureWhenErrorFutureError(); |
| 652 | 668 |
| 653 testFutureThenThrowsAsync(); | 669 testFutureThenThrowsAsync(); |
| 654 testFutureCatchThrowsAsync(); | 670 testFutureCatchThrowsAsync(); |
| 655 testFutureWhenThrowsAsync(); | 671 testFutureWhenThrowsAsync(); |
| 656 testFutureCatchRethrowsAsync(); | 672 testFutureCatchRethrowsAsync(); |
| 657 | 673 |
| 658 testChainedFutureValue(); | 674 testChainedFutureValue(); |
| 659 testChainedFutureValueDelay(); | 675 testChainedFutureValueDelay(); |
| 660 testChainedFutureError(); | 676 testChainedFutureError(); |
| 677 testChainedFutureCycle(); |
| 661 } | 678 } |
| OLD | NEW |