OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Support for writing Dart unit tests. | 5 /// Support for writing Dart unit tests. |
6 /// | 6 /// |
7 /// For information on installing and importing this library, see the | 7 /// For information on installing and importing this library, see the |
8 /// [unittest package on pub.dartlang.org] | 8 /// [unittest package on pub.dartlang.org] |
9 /// (http://pub.dartlang.org/packages/unittest). | 9 /// (http://pub.dartlang.org/packages/unittest). |
10 /// | 10 /// |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 /// expected. [max] can be used to specify an upper bound on the number of | 294 /// expected. [max] can be used to specify an upper bound on the number of |
295 /// calls; if this is exceeded the test will fail (or be marked as in error if | 295 /// calls; if this is exceeded the test will fail (or be marked as in error if |
296 /// it was already complete). A value of 0 for [max] (the default) will set | 296 /// it was already complete). A value of 0 for [max] (the default) will set |
297 /// the upper bound to the same value as [count]; i.e. the callback should be | 297 /// the upper bound to the same value as [count]; i.e. the callback should be |
298 /// called exactly [count] times. A value of -1 for [max] will mean no upper | 298 /// called exactly [count] times. A value of -1 for [max] will mean no upper |
299 /// bound. | 299 /// bound. |
300 Function expectAsync(Function callback, | 300 Function expectAsync(Function callback, |
301 {int count: 1, int max: 0, String id}) => | 301 {int count: 1, int max: 0, String id}) => |
302 new _SpreadArgsHelper(callback, count, max, id).func; | 302 new _SpreadArgsHelper(callback, count, max, id).func; |
303 | 303 |
| 304 /// *Deprecated* |
| 305 /// |
| 306 /// Use [expectAsync] instead. |
| 307 @deprecated |
| 308 Function expectAsync0(Function callback, |
| 309 {int count: 1, int max: 0, String id}) => |
| 310 expectAsync(callback, count: count, max: max, id: id); |
| 311 |
| 312 /// *Deprecated* |
| 313 /// |
| 314 /// Use [expectAsync] instead. |
| 315 @deprecated |
| 316 Function expectAsync1(Function callback, |
| 317 {int count: 1, int max: 0, String id}) => |
| 318 expectAsync(callback, count: count, max: max, id: id); |
| 319 |
304 /// Indicate that [callback] is expected to be called until [isDone] returns | 320 /// Indicate that [callback] is expected to be called until [isDone] returns |
305 /// true. The unittest framework check [isDone] after each callback and only | 321 /// true. The unittest framework check [isDone] after each callback and only |
306 /// when it returns true will it continue with the following test. Using | 322 /// when it returns true will it continue with the following test. Using |
307 /// [expectAsyncUntil] will also ensure that errors that occur within | 323 /// [expectAsyncUntil] will also ensure that errors that occur within |
308 /// [callback] are tracked and reported. [callback] should take 0 positional | 324 /// [callback] are tracked and reported. [callback] should take 0 positional |
309 /// arguments (named arguments are not supported). [id] can be used to | 325 /// arguments (named arguments are not supported). [id] can be used to |
310 /// identify the callback in error messages (for example if it is called | 326 /// identify the callback in error messages (for example if it is called |
311 /// after the test case is complete). | 327 /// after the test case is complete). |
312 Function expectAsyncUntil(Function callback, bool isDone(), {String id}) => | 328 Function expectAsyncUntil(Function callback, bool isDone(), {String id}) => |
313 new _SpreadArgsHelper(callback, 0, -1, id, isDone: isDone).func; | 329 new _SpreadArgsHelper(callback, 0, -1, id, isDone: isDone).func; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 571 |
556 /// A flag that controls whether we try to filter out irrelevant frames from | 572 /// A flag that controls whether we try to filter out irrelevant frames from |
557 /// the stack trace. Requires formatStacks to be set. | 573 /// the stack trace. Requires formatStacks to be set. |
558 bool filterStacks = true; | 574 bool filterStacks = true; |
559 | 575 |
560 void _requireNotRunning() { | 576 void _requireNotRunning() { |
561 if (_currentTestCaseIndex != -1) { | 577 if (_currentTestCaseIndex != -1) { |
562 throw new StateError('Not allowed when tests are running.'); | 578 throw new StateError('Not allowed when tests are running.'); |
563 } | 579 } |
564 } | 580 } |
OLD | NEW |