| 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 /// Matchers build up their error messages by appending to | 8 /// Matchers build up their error messages by appending to |
| 9 /// Description objects. This interface is implemented by | 9 /// Description objects. This interface is implemented by |
| 10 /// StringDescription. This interface is unlikely to need | 10 /// StringDescription. This interface is unlikely to need |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 /// This is used to add a meaningful description of a value. | 22 /// This is used to add a meaningful description of a value. |
| 23 Description addDescriptionOf(value); | 23 Description addDescriptionOf(value); |
| 24 | 24 |
| 25 /// This is used to add a description of an [Iterable] [list], | 25 /// This is used to add a description of an [Iterable] [list], |
| 26 /// with appropriate [start] and [end] markers and inter-element [separator]. | 26 /// with appropriate [start] and [end] markers and inter-element [separator]. |
| 27 Description addAll(String start, String separator, String end, Iterable list); | 27 Description addAll(String start, String separator, String end, Iterable list); |
| 28 } | 28 } |
| 29 | 29 |
| 30 /// [expect] Matchers must implement/extend the Matcher class. | 30 /// [expect] Matchers must implement/extend the Matcher class. |
| 31 /// |
| 31 /// The base Matcher class has a generic implementation of [describeMismatch] | 32 /// The base Matcher class has a generic implementation of [describeMismatch] |
| 32 /// so this does not need to be provided unless a more clear description is | 33 /// so this does not need to be provided unless a more clear description is |
| 33 /// required. The other two methods ([matches] and [describe]) | 34 /// required. The other two methods ([matches] and [describe]) |
| 34 /// must always be provided as they are highly matcher-specific. | 35 /// must always be provided as they are highly matcher-specific. |
| 35 abstract class Matcher { | 36 abstract class Matcher { |
| 36 const Matcher(); | 37 const Matcher(); |
| 37 | 38 |
| 38 /// This does the matching of the actual vs expected values. | 39 /// This does the matching of the actual vs expected values. |
| 39 /// [item] is the actual value. [matchState] can be supplied | 40 /// [item] is the actual value. [matchState] can be supplied |
| 40 /// and may be used to add details about the mismatch that are too | 41 /// and may be used to add details about the mismatch that are too |
| 41 /// costly to determine in [describeMismatch]. | 42 /// costly to determine in [describeMismatch]. |
| 42 bool matches(item, Map matchState); | 43 bool matches(item, Map matchState); |
| 43 | 44 |
| 44 /// This builds a textual description of the matcher. | 45 /// This builds a textual description of the matcher. |
| 45 Description describe(Description description); | 46 Description describe(Description description); |
| 46 | 47 |
| 47 /// This builds a textual description of a specific mismatch. [item] | 48 /// This builds a textual description of a specific mismatch. [item] |
| 48 /// is the value that was tested by [matches]; [matchState] is | 49 /// is the value that was tested by [matches]; [matchState] is |
| 49 /// the [Map] that was passed to and supplemented by [matches] | 50 /// the [Map] that was passed to and supplemented by [matches] |
| 50 /// with additional information about the mismatch, and [mismatchDescription] | 51 /// with additional information about the mismatch, and [mismatchDescription] |
| 51 /// is the [Description] that is being built to decribe the mismatch. | 52 /// is the [Description] that is being built to describe the mismatch. |
| 52 /// A few matchers make use of the [verbose] flag to provide detailed | 53 /// A few matchers make use of the [verbose] flag to provide detailed |
| 53 /// information that is not typically included but can be of help in | 54 /// information that is not typically included but can be of help in |
| 54 /// diagnosing failures, such as stack traces. | 55 /// diagnosing failures, such as stack traces. |
| 55 Description describeMismatch(item, Description mismatchDescription, | 56 Description describeMismatch(item, Description mismatchDescription, |
| 56 Map matchState, bool verbose) => | 57 Map matchState, bool verbose) => |
| 57 mismatchDescription; | 58 mismatchDescription; |
| 58 } | 59 } |
| OLD | NEW |