| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 compare(() { | 48 compare(() { |
| 49 hasExecuted = true; | 49 hasExecuted = true; |
| 50 return 499; | 50 return 499; |
| 51 }); | 51 }); |
| 52 Expect.isTrue(hasExecuted); | 52 Expect.isTrue(hasExecuted); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void testNeverComplete() { | 55 void testNeverComplete() { |
| 56 final completer = new Completer<int>(); | 56 final completer = new Completer<int>(); |
| 57 final future = completer.future; | 57 final future = completer.future; |
| 58 future.then((v) => Expect.fails("Value not expected")); | 58 future.then((v) => Expect.fail("Value not expected")); |
| 59 future.catchError((e) => Expect.fails("Value not expected")); | 59 future.catchError((e) => Expect.fail("Value not expected")); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void testComplete() { | 62 void testComplete() { |
| 63 final completer = new Completer<int>(); | 63 final completer = new Completer<int>(); |
| 64 final future = completer.future; | 64 final future = completer.future; |
| 65 Expect.isFalse(completer.isCompleted); | 65 Expect.isFalse(completer.isCompleted); |
| 66 | 66 |
| 67 completer.complete(3); | 67 completer.complete(3); |
| 68 Expect.isTrue(completer.isCompleted); | 68 Expect.isTrue(completer.isCompleted); |
| 69 | 69 |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 CustomFuture(this._realFuture); | 805 CustomFuture(this._realFuture); |
| 806 Future then(action(result), {Function onError}) => | 806 Future then(action(result), {Function onError}) => |
| 807 _realFuture.then(action, onError: onError); | 807 _realFuture.then(action, onError: onError); |
| 808 Future catchError(Function onError, {bool test(e)}) => | 808 Future catchError(Function onError, {bool test(e)}) => |
| 809 _realFuture.catchError(onError, test: test); | 809 _realFuture.catchError(onError, test: test); |
| 810 Future whenComplete(action()) => _realFuture.whenComplete(action); | 810 Future whenComplete(action()) => _realFuture.whenComplete(action); |
| 811 Stream asStream() => _realFuture.asStream(); | 811 Stream asStream() => _realFuture.asStream(); |
| 812 String toString() => "CustomFuture@${_realFuture.hashCode}"; | 812 String toString() => "CustomFuture@${_realFuture.hashCode}"; |
| 813 int get hashCode => _realFuture.hashCode; | 813 int get hashCode => _realFuture.hashCode; |
| 814 } | 814 } |
| OLD | NEW |