| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 void failed() { | 173 void failed() { |
| 174 testCase.tearDown(); | 174 testCase.tearDown(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 Promise completes(Promise promise) { | 177 Promise completes(Promise promise) { |
| 178 Promise result = new TestPromise(this); | 178 Promise result = new TestPromise(this); |
| 179 promise.then((value) { result.complete(value); }); | 179 promise.then((value) { result.complete(value); }); |
| 180 return result; | 180 return result; |
| 181 } | 181 } |
| 182 | 182 |
| 183 Promise completesWithValue(Promise promise, var expected) { |
| 184 Promise result = new TestPromise(this); |
| 185 promise.then((value) { |
| 186 Expect.equals(expected, value); |
| 187 result.complete(value); |
| 188 }); |
| 189 return result; |
| 190 } |
| 191 |
| 183 Function runs0(Function fn) { | 192 Function runs0(Function fn) { |
| 184 bool ran = false; // We only check that the function is executed once. | 193 bool ran = false; // We only check that the function is executed once. |
| 185 pendingCallbacks++; | 194 pendingCallbacks++; |
| 186 return () { | 195 return () { |
| 187 if (!ran) pendingCallbacks--; | 196 if (!ran) pendingCallbacks--; |
| 188 ran = true; | 197 ran = true; |
| 189 return result.runGuarded(testCase, () => fn()); | 198 return result.runGuarded(testCase, () => fn()); |
| 190 }; | 199 }; |
| 191 } | 200 } |
| 192 | 201 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 283 |
| 275 void addCompleteHandler(void completeHandler(T result)) { | 284 void addCompleteHandler(void completeHandler(T result)) { |
| 276 super.addCompleteHandler(expect.runs1((T result) { | 285 super.addCompleteHandler(expect.runs1((T result) { |
| 277 completeHandler(result); | 286 completeHandler(result); |
| 278 })); | 287 })); |
| 279 } | 288 } |
| 280 | 289 |
| 281 final TestExpectation expect; | 290 final TestExpectation expect; |
| 282 | 291 |
| 283 } | 292 } |
| OLD | NEW |