| 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 | |
| 320 /// Indicate that [callback] is expected to be called until [isDone] returns | 304 /// Indicate that [callback] is expected to be called until [isDone] returns |
| 321 /// true. The unittest framework check [isDone] after each callback and only | 305 /// true. The unittest framework check [isDone] after each callback and only |
| 322 /// when it returns true will it continue with the following test. Using | 306 /// when it returns true will it continue with the following test. Using |
| 323 /// [expectAsyncUntil] will also ensure that errors that occur within | 307 /// [expectAsyncUntil] will also ensure that errors that occur within |
| 324 /// [callback] are tracked and reported. [callback] should take 0 positional | 308 /// [callback] are tracked and reported. [callback] should take 0 positional |
| 325 /// arguments (named arguments are not supported). [id] can be used to | 309 /// arguments (named arguments are not supported). [id] can be used to |
| 326 /// identify the callback in error messages (for example if it is called | 310 /// identify the callback in error messages (for example if it is called |
| 327 /// after the test case is complete). | 311 /// after the test case is complete). |
| 328 Function expectAsyncUntil(Function callback, bool isDone(), {String id}) => | 312 Function expectAsyncUntil(Function callback, bool isDone(), {String id}) => |
| 329 new _SpreadArgsHelper(callback, 0, -1, id, isDone: isDone).func; | 313 new _SpreadArgsHelper(callback, 0, -1, id, isDone: isDone).func; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 555 |
| 572 /// A flag that controls whether we try to filter out irrelevant frames from | 556 /// A flag that controls whether we try to filter out irrelevant frames from |
| 573 /// the stack trace. Requires formatStacks to be set. | 557 /// the stack trace. Requires formatStacks to be set. |
| 574 bool filterStacks = true; | 558 bool filterStacks = true; |
| 575 | 559 |
| 576 void _requireNotRunning() { | 560 void _requireNotRunning() { |
| 577 if (_currentTestCaseIndex != -1) { | 561 if (_currentTestCaseIndex != -1) { |
| 578 throw new StateError('Not allowed when tests are running.'); | 562 throw new StateError('Not allowed when tests are running.'); |
| 579 } | 563 } |
| 580 } | 564 } |
| OLD | NEW |