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

Side by Side Diff: tests/lib/async/future_test.dart

Issue 12387012: Fix mising rename in tests of Future.isCompleted. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: All of them Created 7 years, 9 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 | « no previous file | 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) 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 'dart:async'; 7 import 'dart:async';
8 import 'dart:isolate'; 8 import 'dart:isolate';
9 9
10 const Duration MS = const Duration(milliseconds: 1); 10 const Duration MS = const Duration(milliseconds: 1);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 testNeverComplete() { 46 testNeverComplete() {
47 final completer = new Completer<int>(); 47 final completer = new Completer<int>();
48 final future = completer.future; 48 final future = completer.future;
49 future.then((v) => Expect.fails("Value not expected")); 49 future.then((v) => Expect.fails("Value not expected"));
50 future.catchError((e) => Expect.fails("Value not expected")); 50 future.catchError((e) => Expect.fails("Value not expected"));
51 } 51 }
52 52
53 testComplete() { 53 testComplete() {
54 final completer = new Completer<int>(); 54 final completer = new Completer<int>();
55 final future = completer.future; 55 final future = completer.future;
56 Expect.isFalse(completer.completed); 56 Expect.isFalse(completer.isCompleted);
57 57
58 completer.complete(3); 58 completer.complete(3);
59 Expect.isTrue(completer.completed); 59 Expect.isTrue(completer.isCompleted);
60 60
61 future.then((v) => Expect.equals(3, v)); 61 future.then((v) => Expect.equals(3, v));
62 } 62 }
63 63
64 // Tests for [then] 64 // Tests for [then]
65 65
66 testCompleteWithSuccessHandlerBeforeComplete() { 66 testCompleteWithSuccessHandlerBeforeComplete() {
67 final completer = new Completer<int>(); 67 final completer = new Completer<int>();
68 final future = completer.future; 68 final future = completer.future;
69 69
70 int value; 70 int value;
71 future.then((int v) { value = v; }); 71 future.then((int v) { value = v; });
72 Expect.isNull(value); 72 Expect.isNull(value);
73 73
74 Expect.isFalse(completer.completed); 74 Expect.isFalse(completer.isCompleted);
75 completer.complete(3); 75 completer.complete(3);
76 Expect.isTrue(completer.completed); 76 Expect.isTrue(completer.isCompleted);
77 77
78 Expect.equals(3, value); 78 Expect.equals(3, value);
79 } 79 }
80 80
81 testCompleteWithSuccessHandlerAfterComplete() { 81 testCompleteWithSuccessHandlerAfterComplete() {
82 final completer = new Completer<int>(); 82 final completer = new Completer<int>();
83 final future = completer.future; 83 final future = completer.future;
84 84
85 int after; 85 int after;
86 completer.complete(3); 86 completer.complete(3);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 135
136 testExceptionHandler() { 136 testExceptionHandler() {
137 final completer = new Completer<int>(); 137 final completer = new Completer<int>();
138 final future = completer.future; 138 final future = completer.future;
139 final ex = new Exception(); 139 final ex = new Exception();
140 140
141 var ex2; 141 var ex2;
142 var done = future.catchError((e) { ex2 = e.error; }); 142 var done = future.catchError((e) { ex2 = e.error; });
143 143
144 Expect.isFalse(completer.completed); 144 Expect.isFalse(completer.isCompleted);
145 completer.completeError(ex); 145 completer.completeError(ex);
146 Expect.isTrue(completer.completed); 146 Expect.isTrue(completer.isCompleted);
147 147
148 var port = new ReceivePort(); 148 var port = new ReceivePort();
149 done.then((_) { 149 done.then((_) {
150 Expect.equals(ex, ex2); 150 Expect.equals(ex, ex2);
151 port.close(); 151 port.close();
152 }); 152 });
153 } 153 }
154 154
155 testExceptionHandlerReturnsTrue() { 155 testExceptionHandlerReturnsTrue() {
156 final completer = new Completer<int>(); 156 final completer = new Completer<int>();
157 final future = completer.future; 157 final future = completer.future;
158 final ex = new Exception(); 158 final ex = new Exception();
159 159
160 bool reached = false; 160 bool reached = false;
161 future.catchError((e) { }); 161 future.catchError((e) { });
162 future.catchError((e) { reached = true; }, test: (e) => false) 162 future.catchError((e) { reached = true; }, test: (e) => false)
163 .catchError((e) {}); 163 .catchError((e) {});
164 Expect.isFalse(completer.completed); 164 Expect.isFalse(completer.isCompleted);
165 completer.completeError(ex); 165 completer.completeError(ex);
166 Expect.isTrue(completer.completed); 166 Expect.isTrue(completer.isCompleted);
167 Expect.isFalse(reached); 167 Expect.isFalse(reached);
168 } 168 }
169 169
170 testExceptionHandlerReturnsTrue2() { 170 testExceptionHandlerReturnsTrue2() {
171 final completer = new Completer<int>(); 171 final completer = new Completer<int>();
172 final future = completer.future; 172 final future = completer.future;
173 final ex = new Exception(); 173 final ex = new Exception();
174 174
175 bool reached = false; 175 bool reached = false;
176 var done = future 176 var done = future
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 testFutureCatchThrowsAsync(); 642 testFutureCatchThrowsAsync();
643 testFutureWhenThrowsAsync(); 643 testFutureWhenThrowsAsync();
644 testFutureCatchRethrowsAsync(); 644 testFutureCatchRethrowsAsync();
645 645
646 testChainedFutureValue(); 646 testChainedFutureValue();
647 testChainedFutureValueDelay(); 647 testChainedFutureValueDelay();
648 testChainedFutureError(); 648 testChainedFutureError();
649 } 649 }
650 650
651 651
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698