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

Side by Side Diff: pkg/unittest/lib/src/interfaces.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
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 // To decouple the reporting of errors, and allow for extensibility of 7 // To decouple the reporting of errors, and allow for extensibility of
8 // matchers, we make use of some interfaces. 8 // matchers, we make use of some interfaces.
9 9
10 /** 10 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 /** 46 /**
47 * [expect] Matchers must implement the Matcher class. 47 * [expect] Matchers must implement the Matcher class.
48 * The base Matcher class that implements this interface has 48 * The base Matcher class that implements this interface has
49 * a generic implementation of [describeMismatch] so this does 49 * a generic implementation of [describeMismatch] so this does
50 * not need to be provided unless a more clear description is 50 * not need to be provided unless a more clear description is
51 * required. The other two methods ([matches] and [describe]) 51 * required. The other two methods ([matches] and [describe])
52 * must always be provided as they are highly matcher-specific. 52 * must always be provided as they are highly matcher-specific.
53 */ 53 */
54 abstract class Matcher { 54 abstract class Matcher {
55 /** 55 /**
56 * Whether failures should include the actual value in the output.
57 * The reason is passed in so that it can be inspected if necessary
58 * for some more complex cases.
59 */
60 bool includeActual(reason) => true;
61
62 /**
56 * This does the matching of the actual vs expected values. 63 * This does the matching of the actual vs expected values.
57 * [item] is the actual value. [matchState] can be supplied 64 * [item] is the actual value. [matchState] can be supplied
58 * and may be used to add details about the mismatch that are too 65 * and may be used to add details about the mismatch that are too
59 * costly to determine in [describeMismatch]. 66 * costly to determine in [describeMismatch].
60 */ 67 */
61 bool matches(item, MatchState matchState); 68 bool matches(item, MatchState matchState);
62 69
63 /** This builds a textual description of the matcher. */ 70 /** This builds a textual description of the matcher. */
64 Description describe(Description description); 71 Description describe(Description description);
65 72
(...skipping 26 matching lines...) Expand all
92 * the [reason] (argument from [expect]), some additonal [matchState] 99 * the [reason] (argument from [expect]), some additonal [matchState]
93 * generated by the [matcher], and a verbose flag which controls in 100 * generated by the [matcher], and a verbose flag which controls in
94 * some cases how much [matchState] information is used. It will use 101 * some cases how much [matchState] information is used. It will use
95 * these to create a detailed error message (typically by calling 102 * these to create a detailed error message (typically by calling
96 * an [ErrorFormatter]) and then call [fail] with this message. 103 * an [ErrorFormatter]) and then call [fail] with this message.
97 */ 104 */
98 void failMatch(actual, Matcher matcher, String reason, 105 void failMatch(actual, Matcher matcher, String reason,
99 MatchState matchState, bool verbose); 106 MatchState matchState, bool verbose);
100 } 107 }
101 108
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698