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 part of matcher; |
| 6 |
5 /** | 7 /** |
6 * MatchState is a simple wrapper around an arbitrary object. | 8 * MatchState is a simple wrapper around an arbitrary object. |
7 * [Matcher] [matches] methods can use this to store useful | 9 * [Matcher] [matches] methods can use this to store useful |
8 * information upon match failures, and this information will | 10 * information upon match failures, and this information will |
9 * be passed to [describeMismatch]. Each [Matcher] is responsible | 11 * be passed to [describeMismatch]. Each [Matcher] is responsible |
10 * for its own use of this state, so the state created by [matches] | 12 * for its own use of this state, so the state created by [matches] |
11 * should be consistent with that expected by [describeMismatch] in | 13 * should be consistent with that expected by [describeMismatch] in |
12 * the same [Matcher] class, but can vary between classes. The inner | 14 * the same [Matcher] class, but can vary between classes. The inner |
13 * state, if set, will typically be a [Map] with a number of key-value | 15 * state, if set, will typically be a [Map] with a number of key-value |
14 * pairs containing relevant state information. | 16 * pairs containing relevant state information. |
15 */ | 17 */ |
16 | |
17 part of unittest; | |
18 | |
19 class MatchState { | 18 class MatchState { |
20 var state = null; | 19 var state = null; |
21 | 20 |
22 MatchState([this.state]); | 21 MatchState([this.state]); |
23 } | 22 } |
24 | 23 |
25 /** | 24 /** |
26 * BaseMatcher is the base class for all matchers. To implement a new | 25 * BaseMatcher is the base class for all matchers. To implement a new |
27 * matcher, either add a class that implements from IMatcher or | 26 * matcher, either add a class that implements from IMatcher or |
28 * a class that inherits from Matcher. Inheriting from Matcher has | 27 * a class that inherits from Matcher. Inheriting from Matcher has |
(...skipping 21 matching lines...) Expand all Loading... |
50 * Generates a description of the matcher failed for a particular | 49 * Generates a description of the matcher failed for a particular |
51 * [item], by appending the description to [mismatchDescription]. | 50 * [item], by appending the description to [mismatchDescription]. |
52 * It does not check whether the [item] fails the match, as it is | 51 * It does not check whether the [item] fails the match, as it is |
53 * only called after a failed match. There may be additional info | 52 * only called after a failed match. There may be additional info |
54 * about the mismatch in [matchState]. | 53 * about the mismatch in [matchState]. |
55 */ | 54 */ |
56 Description describeMismatch(item, Description mismatchDescription, | 55 Description describeMismatch(item, Description mismatchDescription, |
57 MatchState matchState, bool verbose) => | 56 MatchState matchState, bool verbose) => |
58 mismatchDescription.add('was ').addDescriptionOf(item); | 57 mismatchDescription.add('was ').addDescriptionOf(item); |
59 } | 58 } |
OLD | NEW |