Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: pkg/unittest/lib/src/basematcher.dart

Issue 15755005: Change output of string equality match failures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/unittest/lib/src/core_matchers.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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; 5 part of matcher;
6 6
7 /** 7 /**
8 * MatchState is a simple wrapper around an arbitrary object. 8 * MatchState is a simple wrapper around an arbitrary object.
9 * [Matcher] [matches] methods can use this to store useful 9 * [Matcher] [matches] methods can use this to store useful
10 * information upon match failures, and this information will 10 * information upon match failures, and this information will
(...skipping 13 matching lines...) Expand all
24 /** 24 /**
25 * 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
26 * matcher, either add a class that implements Matcher or a class that 26 * matcher, either add a class that implements Matcher or a class that
27 * extends BaseMatcher. Extending BaseMatcher has the benefit that a 27 * extends BaseMatcher. Extending BaseMatcher has the benefit that a
28 * default implementation of describeMismatch will be provided. 28 * default implementation of describeMismatch will be provided.
29 */ 29 */
30 abstract class BaseMatcher implements Matcher { 30 abstract class BaseMatcher implements Matcher {
31 const BaseMatcher(); 31 const BaseMatcher();
32 32
33 /** 33 /**
34 * Whether failures should include the actual value in the output.
35 * The reason is passed in so that it can be inspected if necessary
36 * for some more complex cases.
37 */
38 bool includeActual(reason) => !reason.toString().startsWith('was ');
Siggi Cherem (dart-lang) 2013/05/23 00:43:47 2 comments: a) how about storing a boolean propert
39
40
41 /**
34 * Tests the matcher against a given [item] 42 * Tests the matcher against a given [item]
35 * and return true if the match succeeds; false otherwise. 43 * and return true if the match succeeds; false otherwise.
36 * [matchState] may be used to return additional info for 44 * [matchState] may be used to return additional info for
37 * the use of [describeMismatch]. 45 * the use of [describeMismatch].
38 */ 46 */
39 bool matches(item, MatchState matchState); 47 bool matches(item, MatchState matchState);
40 48
41 /** 49 /**
42 * Creates a textual description of a matcher, 50 * Creates a textual description of a matcher,
43 * by appending to [mismatchDescription]. 51 * by appending to [mismatchDescription].
44 */ 52 */
45 Description describe(Description mismatchDescription); 53 Description describe(Description mismatchDescription);
46 54
47 /** 55 /**
48 * Generates a description of the matcher failed for a particular 56 * Generates a description of the matcher failed for a particular
49 * [item], by appending the description to [mismatchDescription]. 57 * [item], by appending the description to [mismatchDescription].
50 * It does not check whether the [item] fails the match, as it is 58 * It does not check whether the [item] fails the match, as it is
51 * only called after a failed match. There may be additional info 59 * only called after a failed match. There may be additional info
52 * about the mismatch in [matchState]. 60 * about the mismatch in [matchState].
53 */ 61 */
54 Description describeMismatch(item, Description mismatchDescription, 62 Description describeMismatch(item, Description mismatchDescription,
55 MatchState matchState, bool verbose) => 63 MatchState matchState, bool verbose) =>
56 mismatchDescription.add('was ').addDescriptionOf(item); 64 mismatchDescription.add('was ').addDescriptionOf(item);
57 } 65 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/src/core_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698