| 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 Expect.fail("Shouldn't happen"); | 670 Expect.fail("Shouldn't happen"); |
| 671 }, onError: (Future f) { | 671 }, onError: (Future f) { |
| 672 f.then((v) { | 672 f.then((v) { |
| 673 Expect.equals(42, v); | 673 Expect.equals(42, v); |
| 674 asyncEnd(); | 674 asyncEnd(); |
| 675 }); | 675 }); |
| 676 }); | 676 }); |
| 677 } | 677 } |
| 678 | 678 |
| 679 void testCompleteErrorWithNull() { | 679 void testCompleteErrorWithNull() { |
| 680 asyncStart(); |
| 680 final completer = new Completer<int>(); | 681 final completer = new Completer<int>(); |
| 681 Expect.throws(() => completer.completeError(null)); | 682 completer.future.catchError((e) { |
| 683 Expect.isTrue(e is NullThrownError); |
| 684 asyncEnd(); |
| 685 }); |
| 686 completer.completeError(null); |
| 682 } | 687 } |
| 683 | 688 |
| 684 void testChainedFutureValue() { | 689 void testChainedFutureValue() { |
| 685 final completer = new Completer(); | 690 final completer = new Completer(); |
| 686 final future = completer.future; | 691 final future = completer.future; |
| 687 asyncStart(); | 692 asyncStart(); |
| 688 | 693 |
| 689 future.then((v) => new Future.value(v * 2)) | 694 future.then((v) => new Future.value(v * 2)) |
| 690 .then((v) { | 695 .then((v) { |
| 691 Expect.equals(42, v); | 696 Expect.equals(42, v); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 _realFuture.then(action, onError: onError); | 816 _realFuture.then(action, onError: onError); |
| 812 Future catchError(Function onError, {bool test(e)}) => | 817 Future catchError(Function onError, {bool test(e)}) => |
| 813 _realFuture.catchError(onError, test: test); | 818 _realFuture.catchError(onError, test: test); |
| 814 Future whenComplete(action()) => _realFuture.whenComplete(action); | 819 Future whenComplete(action()) => _realFuture.whenComplete(action); |
| 815 Future timeout(Duration timeLimit, {void onTimeout()}) => | 820 Future timeout(Duration timeLimit, {void onTimeout()}) => |
| 816 _realFuture.timeout(timeLimit, onTimeout: onTimeout); | 821 _realFuture.timeout(timeLimit, onTimeout: onTimeout); |
| 817 Stream asStream() => _realFuture.asStream(); | 822 Stream asStream() => _realFuture.asStream(); |
| 818 String toString() => "CustomFuture@${_realFuture.hashCode}"; | 823 String toString() => "CustomFuture@${_realFuture.hashCode}"; |
| 819 int get hashCode => _realFuture.hashCode; | 824 int get hashCode => _realFuture.hashCode; |
| 820 } | 825 } |
| OLD | NEW |