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 /** | 5 /** |
6 * A library for writing dart unit tests. | 6 * A library for writing dart unit tests. |
7 * | 7 * |
8 * ##Concepts## | 8 * ##Concepts## |
9 * | 9 * |
10 * * Tests: Tests are specified via the top-level function [test], they can be | 10 * * Tests: Tests are specified via the top-level function [test], they can be |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 258 } |
259 | 259 |
260 /** Called by subclasses to indicate that an asynchronous test completed. */ | 260 /** Called by subclasses to indicate that an asynchronous test completed. */ |
261 void callbackDone() { | 261 void callbackDone() { |
262 _callbacksCalled++; | 262 _callbacksCalled++; |
263 final testCase = _tests[_currentTest]; | 263 final testCase = _tests[_currentTest]; |
264 if (_callbacksCalled > testCase.callbacks) { | 264 if (_callbacksCalled > testCase.callbacks) { |
265 final expected = testCase.callbacks; | 265 final expected = testCase.callbacks; |
266 testCase.error( | 266 testCase.error( |
267 'More calls to callbackDone() than expected. ' | 267 'More calls to callbackDone() than expected. ' |
268 + 'Actual: ${_callbacksCalled}, expected: ${expected}', ''); | 268 'Actual: ${_callbacksCalled}, expected: ${expected}', ''); |
269 _state = _UNCAUGHT_ERROR; | 269 _state = _UNCAUGHT_ERROR; |
270 } else if ((_callbacksCalled == testCase.callbacks) && | 270 } else if ((_callbacksCalled == testCase.callbacks) && |
271 (_state != _RUNNING_TEST)) { | 271 (_state != _RUNNING_TEST)) { |
272 if (testCase.result == null) testCase.pass(); | 272 if (testCase.result == null) testCase.pass(); |
273 _currentTest++; | 273 _currentTest++; |
274 _testRunner(); | 274 _testRunner(); |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 void notifyError(String msg, String trace) { | 278 void notifyError(String msg, String trace) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 404 } |
405 _config.onInit(); | 405 _config.onInit(); |
406 | 406 |
407 // Immediately queue the suite up. It will run after a timeout (i.e. after | 407 // Immediately queue the suite up. It will run after a timeout (i.e. after |
408 // main() has returned). | 408 // main() has returned). |
409 _defer(_runTests); | 409 _defer(_runTests); |
410 } | 410 } |
411 | 411 |
412 /** Signature for a test function. */ | 412 /** Signature for a test function. */ |
413 typedef void TestFunction(); | 413 typedef void TestFunction(); |
OLD | NEW |