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

Unified Diff: lib/unittest/interfaces.dart

Issue 10832058: Improved the way we generate mismatch descriptions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/unittest/future_matchers.dart ('k') | lib/unittest/map_matchers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/interfaces.dart
===================================================================
--- lib/unittest/interfaces.dart (revision 10002)
+++ lib/unittest/interfaces.dart (working copy)
@@ -13,7 +13,8 @@
* is replaced it may be desirable to replace the [stringDescription]
* error formatter with another.
*/
-typedef String ErrorFormatter(actual, Matcher matcher, String reason);
+typedef String ErrorFormatter(actual, Matcher matcher, String reason,
+ MatchState matchState, bool verbose);
/**
* Matchers build up their error messages by appending to
@@ -49,14 +50,29 @@
* must always be provided as they are highly matcher-specific.
*/
interface Matcher {
- /** This does the matching of the actual vs expected values. */
- bool matches(item);
+ /**
+ * This does the matching of the actual vs expected values.
+ * [item] is the actual value. [matchState] can be supplied
+ * and may be used to add details about the mismatch that are too
+ * costly to determine in [describeMismatch].
+ */
+ bool matches(item, MatchState matchState);
/** This builds a textual description of the matcher. */
Description describe(Description description);
- /**This builds a textual description of a specific mismatch. */
- Description describeMismatch(item, Description mismatchDescription);
+ /**
+ * This builds a textual description of a specific mismatch. [item]
+ * is the value that was tested by [matches]; [matchState] is
+ * the [MatchState] that was passed to and supplemented by [matches]
+ * with additional information about the mismact, and [mismatchDescription]
+ * is the [Description] that is being built to decribe the mismatch.
+ * A few matchers make use of the [verbose] flag to provide detailed
+ * information that is not typically included but can be of help in
+ * diagnosing failures, such as stack traces.
+ */
+ Description describeMismatch(item, Description mismatchDescription,
+ MatchState matchState, bool verbose);
}
/**
@@ -71,10 +87,13 @@
/**
* This handles failures given the actual [value], the [matcher]
- * and the [reason]. It will typically use these to create a
- * detailed error message (typically using an [ErrorFormatter])
- * and then call [fail].
+ * the [reason] (argument from [expect]), some additonal [matchState]
+ * generated by the [matcher], and a verbose flag which controls in
+ * some cases how much [matchState] information is used. It will use
+ * these to create a detailed error message (typically by calling
+ * an [ErrorFormatter]) and then call [fail] with this message.
*/
- void failMatch(actual, Matcher matcher, String reason);
+ void failMatch(actual, Matcher matcher, String reason,
+ MatchState matchState, bool verbose);
}
« no previous file with comments | « lib/unittest/future_matchers.dart ('k') | lib/unittest/map_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698