| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // To decouple the reporting of errors, and allow for extensibility of | 5 // To decouple the reporting of errors, and allow for extensibility of |
| 6 // matchers, we make use of some interfaces. | 6 // matchers, we make use of some interfaces. |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * The ErrorFormatter type is used for functions that | 9 * The ErrorFormatter type is used for functions that |
| 10 * can be used to build up error reports upon [expect] failures. | 10 * can be used to build up error reports upon [expect] failures. |
| 11 * There is one built-in implementation ([defaultErrorFormatter]) | 11 * There is one built-in implementation ([defaultErrorFormatter]) |
| 12 * which is used by the default failure handler. If the failure handler | 12 * which is used by the default failure handler. If the failure handler |
| 13 * is replaced it may be desirable to replace the [stringDescription] | 13 * is replaced it may be desirable to replace the [stringDescription] |
| 14 * error formatter with another. | 14 * error formatter with another. |
| 15 */ | 15 */ |
| 16 typedef String ErrorFormatter(actual, Matcher matcher, String reason); | 16 typedef String ErrorFormatter(actual, Matcher matcher, String reason); |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Matchers build up their error messages by appending to | 19 * Matchers build up their error messages by appending to |
| 20 * Description objects. This interface is implemented by | 20 * Description objects. This interface is implemented by |
| 21 * StringDescription. This interface is unlikely to need | 21 * StringDescription. This interface is unlikely to need |
| 22 * other implementations, but could be useful to replace in | 22 * other implementations, but could be useful to replace in |
| 23 * some cases - e.g. language conversion. | 23 * some cases - e.g. language conversion. |
| 24 */ | 24 */ |
| 25 interface Description { | 25 interface Description { |
| 26 /** Change the value of the description. */ |
| 27 Description replace(String text); |
| 28 |
| 26 /** This is used to add arbitrary text to the description. */ | 29 /** This is used to add arbitrary text to the description. */ |
| 27 Description add(String text); | 30 Description add(String text); |
| 28 | 31 |
| 29 /** This is used to add a meaningful description of a value. */ | 32 /** This is used to add a meaningful description of a value. */ |
| 30 Description addDescriptionOf(value); | 33 Description addDescriptionOf(value); |
| 31 | 34 |
| 32 /** | 35 /** |
| 33 * This is used to add a description of an [Iterable] [list], | 36 * This is used to add a description of an [Iterable] [list], |
| 34 * with appropriate [start] and [end] markers and inter-element [separator]. | 37 * with appropriate [start] and [end] markers and inter-element [separator]. |
| 35 */ | 38 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 71 |
| 69 /** | 72 /** |
| 70 * This handles failures given the actual [value], the [matcher] | 73 * This handles failures given the actual [value], the [matcher] |
| 71 * and the [reason]. It will typically use these to create a | 74 * and the [reason]. It will typically use these to create a |
| 72 * detailed error message (typically using an [ErrorFormatter]) | 75 * detailed error message (typically using an [ErrorFormatter]) |
| 73 * and then call [fail]. | 76 * and then call [fail]. |
| 74 */ | 77 */ |
| 75 void failMatch(actual, Matcher matcher, String reason); | 78 void failMatch(actual, Matcher matcher, String reason); |
| 76 } | 79 } |
| 77 | 80 |
| OLD | NEW |