| 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 return new Future<int>.value(42); | 738 return new Future<int>.value(42); |
| 739 }); | 739 }); |
| 740 | 740 |
| 741 future.then((int val) { | 741 future.then((int val) { |
| 742 Expect.equals(val, 42); | 742 Expect.equals(val, 42); |
| 743 asyncEnd(); | 743 asyncEnd(); |
| 744 }); | 744 }); |
| 745 } | 745 } |
| 746 | 746 |
| 747 main() { | 747 main() { |
| 748 asyncStart(); |
| 749 |
| 748 testValue(); | 750 testValue(); |
| 749 testSync(); | 751 testSync(); |
| 750 testNeverComplete(); | 752 testNeverComplete(); |
| 751 | 753 |
| 752 testComplete(); | 754 testComplete(); |
| 753 testCompleteWithSuccessHandlerBeforeComplete(); | 755 testCompleteWithSuccessHandlerBeforeComplete(); |
| 754 testCompleteWithSuccessHandlerAfterComplete(); | 756 testCompleteWithSuccessHandlerAfterComplete(); |
| 755 testCompleteManySuccessHandlers(); | 757 testCompleteManySuccessHandlers(); |
| 756 testCompleteWithError(); | 758 testCompleteWithError(); |
| 757 | 759 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 testFutureThenThrowsAsync(); | 792 testFutureThenThrowsAsync(); |
| 791 testFutureCatchThrowsAsync(); | 793 testFutureCatchThrowsAsync(); |
| 792 testFutureWhenThrowsAsync(); | 794 testFutureWhenThrowsAsync(); |
| 793 testFutureCatchRethrowsAsync(); | 795 testFutureCatchRethrowsAsync(); |
| 794 | 796 |
| 795 testChainedFutureValue(); | 797 testChainedFutureValue(); |
| 796 testChainedFutureValueDelay(); | 798 testChainedFutureValueDelay(); |
| 797 testChainedFutureError(); | 799 testChainedFutureError(); |
| 798 | 800 |
| 799 testSyncFuture_i13368(); | 801 testSyncFuture_i13368(); |
| 802 |
| 803 asyncEnd(); |
| 800 } | 804 } |
| 801 | 805 |
| 802 /// A Future that isn't recognizable as a _Future. | 806 /// A Future that isn't recognizable as a _Future. |
| 803 class CustomFuture<T> implements Future<T> { | 807 class CustomFuture<T> implements Future<T> { |
| 804 Future _realFuture; | 808 Future _realFuture; |
| 805 CustomFuture(this._realFuture); | 809 CustomFuture(this._realFuture); |
| 806 Future then(action(result), {Function onError}) => | 810 Future then(action(result), {Function onError}) => |
| 807 _realFuture.then(action, onError: onError); | 811 _realFuture.then(action, onError: onError); |
| 808 Future catchError(Function onError, {bool test(e)}) => | 812 Future catchError(Function onError, {bool test(e)}) => |
| 809 _realFuture.catchError(onError, test: test); | 813 _realFuture.catchError(onError, test: test); |
| 810 Future whenComplete(action()) => _realFuture.whenComplete(action); | 814 Future whenComplete(action()) => _realFuture.whenComplete(action); |
| 811 Future timeout(Duration timeLimit, {void onTimeout()}) => | 815 Future timeout(Duration timeLimit, {void onTimeout()}) => |
| 812 _realFuture.timeout(timeLimit, onTimeout: onTimeout); | 816 _realFuture.timeout(timeLimit, onTimeout: onTimeout); |
| 813 Stream asStream() => _realFuture.asStream(); | 817 Stream asStream() => _realFuture.asStream(); |
| 814 String toString() => "CustomFuture@${_realFuture.hashCode}"; | 818 String toString() => "CustomFuture@${_realFuture.hashCode}"; |
| 815 int get hashCode => _realFuture.hashCode; | 819 int get hashCode => _realFuture.hashCode; |
| 816 } | 820 } |
| OLD | NEW |