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

Unified Diff: lib/unittest/operator_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/numeric_matchers.dart ('k') | lib/unittest/string_matchers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/operator_matchers.dart
===================================================================
--- lib/unittest/operator_matchers.dart (revision 10002)
+++ lib/unittest/operator_matchers.dart (working copy)
@@ -12,7 +12,8 @@
const _IsNot(Matcher this._matcher);
- bool matches(item) => !_matcher.matches(item);
+ bool matches(item, MatchState matchState) =>
+ !_matcher.matches(item, matchState);
Description describe(Description description) =>
description.add('not ').addDescriptionOf(_matcher);
@@ -75,23 +76,25 @@
const _AllOf(this._matchers);
- bool matches(item) {
+ bool matches(item, MatchState matchState) {
for (var matcher in _matchers) {
- if (!matcher.matches(item)) {
+ if (!matcher.matches(item, matchState)) {
+ matchState.state = {
+ 'matcher': matcher,
+ 'state': matchState.state
+ };
return false;
}
}
return true;
}
- Description describeMismatch(item, Description mismatchDescription) {
- for (var matcher in _matchers) {
- if (!matcher.matches(item)) {
- mismatchDescription.addDescriptionOf(matcher).add(' ');
- matcher.describeMismatch(item, mismatchDescription);
- break;
- }
- }
+ Description describeMismatch(item, Description mismatchDescription,
+ MatchState matchState, bool verbose) {
+ var matcher = matchState.state['matcher'];
+ mismatchDescription.addDescriptionOf(matcher).add(' ');
+ matcher.describeMismatch(item, mismatchDescription,
+ matchState.state['state'], verbose);
return mismatchDescription;
}
@@ -161,9 +164,9 @@
const _AnyOf(this._matchers);
- bool matches(item) {
+ bool matches(item, MatchState matchState) {
for (var matcher in _matchers) {
- if (matcher.matches(item)) {
+ if (matcher.matches(item, matchState)) {
return true;
}
}
« no previous file with comments | « lib/unittest/numeric_matchers.dart ('k') | lib/unittest/string_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698