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

Unified Diff: lib/unittest/string_matchers.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/operator_matchers.dart ('k') | tests/lib/unittest/instance_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/string_matchers.dart
===================================================================
--- lib/unittest/string_matchers.dart (revision 10002)
+++ lib/unittest/string_matchers.dart (working copy)
@@ -16,7 +16,8 @@
_matchValue = _value.toLowerCase();
}
- bool matches(item) => item is String && _matchValue == item.toLowerCase();
+ bool matches(item, MatchState mismatchState) =>
+ item is String && _matchValue == item.toLowerCase();
Description describe(Description description) =>
description.addDescriptionOf(_value).add(' ignoring case');
@@ -41,18 +42,20 @@
_matchValue = collapseWhitespace(_value);
}
- bool matches(item) =>
+ bool matches(item, MatchState matchState) =>
item is String && _matchValue == collapseWhitespace(item);
Description describe(Description description) =>
description.addDescriptionOf(_matchValue).add(' ignoring whitespace');
- Description describeMismatch(item, Description mismatchDescription) {
+ Description describeMismatch(item, Description mismatchDescription,
+ MatchState matchState, bool verbose) {
if (item is String) {
return mismatchDescription.add('was ').
addDescriptionOf(collapseWhitespace(item));
} else {
- return super.describeMismatch(item, mismatchDescription);
+ return super.describeMismatch(item, mismatchDescription,
+ matchState, verbose);
}
}
}
@@ -91,7 +94,8 @@
const _StringStartsWith(this._prefix);
- bool matches(item) => item is String && item.startsWith(_prefix);
+ bool matches(item, MatchState matchState) =>
+ item is String && item.startsWith(_prefix);
Description describe(Description description) =>
description.add('a string starting with ').addDescriptionOf(_prefix);
@@ -109,7 +113,8 @@
const _StringEndsWith(this._suffix);
- bool matches(item) => item is String && item.endsWith(_suffix);
+ bool matches(item, MatchState matchState) =>
+ item is String && item.endsWith(_suffix);
Description describe(Description description) =>
description.add('a string ending with ').addDescriptionOf(_suffix);
@@ -131,7 +136,7 @@
const _StringContainsInOrder(this._substrings);
- bool matches(item) {
+ bool matches(item, MatchState matchState) {
if (!(item is String)) {
return false;
}
@@ -170,7 +175,8 @@
}
}
- bool matches(String item) => _regexp.hasMatch(item);
+ bool matches(String item, MatchState matchState) =>
+ _regexp.hasMatch(item);
Description describe(Description description) =>
description.add("match '${_regexp.pattern}'");
@@ -180,13 +186,15 @@
// class to give better mismatch error messages than the base Matcher class.
/* abstract */ class _StringMatcher extends BaseMatcher {
const _StringMatcher();
- Description describeMismatch(item, Description mismatchDescription) {
+ Description describeMismatch(item, Description mismatchDescription,
+ MatchState matchState, bool verbose) {
if (!(item is String)) {
return mismatchDescription.
addDescriptionOf(item).
add(' not a string');
} else {
- return super.describeMismatch(item, mismatchDescription);
+ return super.describeMismatch(item, mismatchDescription,
+ matchState, verbose);
}
}
}
« no previous file with comments | « lib/unittest/operator_matchers.dart ('k') | tests/lib/unittest/instance_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698