| 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 * To import this library, specify the relative path to lib/unittest.dart. | 8 * To import this library, specify the relative path to |
| 9 * lib/unittest/unittest.dart. |
| 9 * | 10 * |
| 10 * ##Concepts## | 11 * ##Concepts## |
| 11 * | 12 * |
| 12 * * Tests: Tests are specified via the top-level function [test], they can be | 13 * * Tests: Tests are specified via the top-level function [test], they can be |
| 13 * organized together using [group]. | 14 * organized together using [group]. |
| 14 * * Checks: Test expectations can be specified via [expect] (see methods in | 15 * * Checks: Test expectations can be specified via [expect] (see methods in |
| 15 * [Expectation]), [expectThrow], or using assertions with the [Expect] | 16 * [Expectation]), [expectThrow], or using assertions with the [Expect] |
| 16 * class. | 17 * class. |
| 17 * * Configuration: The framework can be adapted by calling [configure] with a | 18 * * Configuration: The framework can be adapted by calling [configure] with a |
| 18 * [Configuration]. Common configurations can be found in this package | 19 * [Configuration]. Common configurations can be found in this package |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 * }, count: 2); // <-- we can indicate multiplicity to [expectAsync0] | 88 * }, count: 2); // <-- we can indicate multiplicity to [expectAsync0] |
| 88 * window.setTimeout(callback, 0); | 89 * window.setTimeout(callback, 0); |
| 89 * window.setTimeout(callback, 0); | 90 * window.setTimeout(callback, 0); |
| 90 * }); | 91 * }); |
| 91 * } | 92 * } |
| 92 * | 93 * |
| 93 * Note: due to some language limitations we have to use different functions | 94 * Note: due to some language limitations we have to use different functions |
| 94 * depending on the number of positional arguments of the callback. In the | 95 * depending on the number of positional arguments of the callback. In the |
| 95 * future, we plan to expose a single `expectAsync` function that can be used | 96 * future, we plan to expose a single `expectAsync` function that can be used |
| 96 * regardless of the number of positional arguments. This requires new langauge | 97 * regardless of the number of positional arguments. This requires new langauge |
| 97 * features or fixes to the current spec (e.g. see dartbug.com/2706). | 98 * features or fixes to the current spec (e.g. see |
| 99 * [Issue 2706](http://dartbug.com/2706)). |
| 98 * | 100 * |
| 99 * Meanwhile, we plan to add this alternative API for callbacks of more than 2 | 101 * Meanwhile, we plan to add this alternative API for callbacks of more than 2 |
| 100 * arguments or that take named parameters. (this is not implemented yet, | 102 * arguments or that take named parameters. (this is not implemented yet, |
| 101 * but will be coming here soon). | 103 * but will be coming here soon). |
| 102 * | 104 * |
| 103 * #import('path-to-dart/lib/unittest/unitest.dart'); | 105 * #import('path-to-dart/lib/unittest/unitest.dart'); |
| 104 * #import('dart:dom_deprecated'); | 106 * #import('dart:dom_deprecated'); |
| 105 * main() { | 107 * main() { |
| 106 * test('calllback is executed', () { | 108 * test('calllback is executed', () { |
| 107 * // indicate ahead of time that an async callback is expected. | 109 * // indicate ahead of time that an async callback is expected. |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 } | 571 } |
| 570 _config.onInit(); | 572 _config.onInit(); |
| 571 | 573 |
| 572 // Immediately queue the suite up. It will run after a timeout (i.e. after | 574 // Immediately queue the suite up. It will run after a timeout (i.e. after |
| 573 // main() has returned). | 575 // main() has returned). |
| 574 _defer(_runTests); | 576 _defer(_runTests); |
| 575 } | 577 } |
| 576 | 578 |
| 577 /** Signature for a test function. */ | 579 /** Signature for a test function. */ |
| 578 typedef void TestFunction(); | 580 typedef void TestFunction(); |
| OLD | NEW |