Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 value_future_test; | 5 library value_future_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:scheduled_test/src/value_future.dart'; | 9 import 'package:scheduled_test/src/value_future.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 group('after successful completion', () { | 91 group('after successful completion', () { |
| 92 var future; | 92 var future; |
| 93 | 93 |
| 94 setUp(() { | 94 setUp(() { |
| 95 var completer = new Completer(); | 95 var completer = new Completer(); |
| 96 future = new ValueFuture(completer.future); | 96 future = new ValueFuture(completer.future); |
| 97 completer.complete(12); | 97 completer.complete(12); |
| 98 }); | 98 }); |
| 99 | 99 |
| 100 test('.value is the result of the future', () { | 100 test('.value is the result of the future', () { |
| 101 expect(future.value, equals(12)); | 101 future.then(expectAsync1((_) { |
| 102 expect(future.value, equals(12)); | |
| 103 })); | |
|
nweiz
2013/05/07 00:11:52
These can be
expect(future.then((_) => future
floitsch
2013/05/13 11:19:25
done in CL 15128002.
| |
| 102 }); | 104 }); |
| 103 | 105 |
| 104 test('.hasValue is true', () { | 106 test('.hasValue is true', () { |
| 105 expect(future.hasValue, isTrue); | 107 future.then(expectAsync1((_) { |
| 108 expect(future.hasValue, isTrue); | |
| 109 })); | |
| 106 }); | 110 }); |
| 107 }); | 111 }); |
| 108 | 112 |
| 109 group('after an error completion', () { | 113 group('after an error completion', () { |
| 110 var future; | 114 var future; |
| 115 var safeFuture; | |
| 111 | 116 |
| 112 setUp(() { | 117 setUp(() { |
| 113 var completer = new Completer(); | 118 var completer = new Completer(); |
| 114 future = new ValueFuture(completer.future); | 119 future = new ValueFuture(completer.future); |
| 115 future.catchError((e) {}); | 120 safeFuture = future.catchError((e) {}); |
| 116 completer.completeError('bad'); | 121 completer.completeError('bad'); |
| 117 }); | 122 }); |
| 118 | 123 |
| 119 test('.value is null', () { | 124 test('.value is null', () { |
| 120 expect(future.value, isNull); | 125 safeFuture.then(expectAsync1((_) { |
| 126 expect(future.value, isNull); | |
| 127 })); | |
| 121 }); | 128 }); |
| 122 | 129 |
| 123 test('.hasValue is false', () { | 130 test('.hasValue is false', () { |
| 124 expect(future.hasValue, isFalse); | 131 safeFuture.then(expectAsync1((_) { |
| 132 expect(future.hasValue, isFalse); | |
| 133 })); | |
| 125 }); | 134 }); |
| 126 }); | 135 }); |
| 127 } | 136 } |
| OLD | NEW |