OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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("TestFramework"); | 5 #library("TestFramework"); |
6 #import("dart:coreimpl"); | 6 #import("dart:coreimpl"); |
7 | 7 |
8 | 8 |
9 typedef void AsynchronousTestFunction(TestExpectation check); | 9 typedef void AsynchronousTestFunction(TestExpectation check); |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 void succeeded() { | 167 void succeeded() { |
168 Expect.equals(0, pendingCallbacks); | 168 Expect.equals(0, pendingCallbacks); |
169 hasSucceeded = true; | 169 hasSucceeded = true; |
170 testCase.tearDown(); | 170 testCase.tearDown(); |
171 } | 171 } |
172 | 172 |
173 void failed() { | 173 void failed() { |
174 testCase.tearDown(); | 174 testCase.tearDown(); |
175 } | 175 } |
176 | 176 |
177 Promise completes(Promise promise) { | 177 Promise completes(var promise) { |
| 178 if (!(promise is Promise || promise is Future)) { |
| 179 // TODO(mattsh) - remove this hack once we finish conversion of |
| 180 // Promise to Future |
| 181 throw "must pass Promise or Future to TestFramework.completes"; |
| 182 } |
| 183 |
178 Promise result = new TestPromise(this); | 184 Promise result = new TestPromise(this); |
179 promise.then((value) { result.complete(value); }); | 185 promise.then((value) { result.complete(value); }); |
180 return result; | 186 return result; |
181 } | 187 } |
182 | 188 |
183 Promise completesWithValue(Promise promise, var expected) { | 189 Promise completesWithValue(Promise promise, var expected) { |
184 Promise result = new TestPromise(this); | 190 Promise result = new TestPromise(this); |
185 promise.then((value) { | 191 promise.then((value) { |
186 Expect.equals(expected, value); | 192 Expect.equals(expected, value); |
187 result.complete(value); | 193 result.complete(value); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 289 |
284 void addCompleteHandler(void completeHandler(T result)) { | 290 void addCompleteHandler(void completeHandler(T result)) { |
285 super.addCompleteHandler(expect.runs1((T result) { | 291 super.addCompleteHandler(expect.runs1((T result) { |
286 completeHandler(result); | 292 completeHandler(result); |
287 })); | 293 })); |
288 } | 294 } |
289 | 295 |
290 final TestExpectation expect; | 296 final TestExpectation expect; |
291 | 297 |
292 } | 298 } |
OLD | NEW |