Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1142)

Side by Side Diff: pkg/scheduled_test/test/value_future_test.dart

Issue 15128002: Address comments from https://codereview.chromium.org/14690009 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing `completion`. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/test/substitute_future_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 future.then(expectAsync1((_) { 101 // The completer calls its listeners asynchronously. We have to wait
102 expect(future.value, equals(12)); 102 // before we can access the value of the ValueFuture.
103 })); 103 expect(future.then((_) => future.value), completion(equals(12)));
104 }); 104 });
105 105
106 test('.hasValue is true', () { 106 test('.hasValue is true', () {
107 future.then(expectAsync1((_) { 107 // The completer calls its listeners asynchronously. We have to wait
108 expect(future.hasValue, isTrue); 108 // before we can access the value of the ValueFuture.
109 })); 109 expect(future.then((_) => future.hasValue), completion(isTrue));
110 }); 110 });
111 }); 111 });
112 112
113 group('after an error completion', () { 113 group('after an error completion', () {
114 var future; 114 var future;
115 // Since the completer completes asynchronously we need to wait before the
116 // ValueFuture has a value. The safeFuture will execute its callback when
117 // this is the case.
115 var safeFuture; 118 var safeFuture;
116 119
117 setUp(() { 120 setUp(() {
118 var completer = new Completer(); 121 var completer = new Completer();
119 future = new ValueFuture(completer.future); 122 future = new ValueFuture(completer.future);
120 safeFuture = future.catchError((e) {}); 123 safeFuture = future.catchError((e) {});
121 completer.completeError('bad'); 124 completer.completeError('bad');
122 }); 125 });
123 126
124 test('.value is null', () { 127 test('.value is null', () {
125 safeFuture.then(expectAsync1((_) { 128 expect(safeFuture.then((_) => future.value), completion(isNull));
126 expect(future.value, isNull);
127 }));
128 }); 129 });
129 130
130 test('.hasValue is false', () { 131 test('.hasValue is false', () {
131 safeFuture.then(expectAsync1((_) { 132 expect(safeFuture.then((_) => future.hasValue), completion(isFalse));
132 expect(future.hasValue, isFalse);
133 }));
134 }); 133 });
135 }); 134 });
136 } 135 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/substitute_future_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698