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

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

Issue 16408019: Improved error messages from unittest. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 /** 7 /**
8 * Returns a matcher which matches if the match argument is greater 8 * Returns a matcher which matches if the match argument is greater
9 * than the given [value]. 9 * than the given [value].
10 */ 10 */
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 Description describe(Description description) { 113 Description describe(Description description) {
114 if (_valueInDescription) { 114 if (_valueInDescription) {
115 return description.add(_comparisonDescription).add(' '). 115 return description.add(_comparisonDescription).add(' ').
116 addDescriptionOf(_value); 116 addDescriptionOf(_value);
117 } else { 117 } else {
118 return description.add(_comparisonDescription); 118 return description.add(_comparisonDescription);
119 } 119 }
120 } 120 }
121
122 Description describeMismatch(item, Description mismatchDescription,
123 MatchState matchState, bool verbose) {
124 mismatchDescription.add('is not ');
125 return describe(mismatchDescription);
126 }
121 } 127 }
122 128
123 /** 129 /**
124 * Returns a matcher which matches if the match argument is within [delta] 130 * Returns a matcher which matches if the match argument is within [delta]
125 * of some [value]; i.e. if the match argument is greater than 131 * of some [value]; i.e. if the match argument is greater than
126 * than or equal [value]-[delta] and less than or equal to [value]+[delta]. 132 * than or equal [value]-[delta] and less than or equal to [value]+[delta].
127 */ 133 */
128 Matcher closeTo(value, delta) => new _IsCloseTo(value, delta); 134 Matcher closeTo(value, delta) => new _IsCloseTo(value, delta);
129 135
130 class _IsCloseTo extends BaseMatcher { 136 class _IsCloseTo extends BaseMatcher {
(...skipping 17 matching lines...) Expand all
148 addDescriptionOf(_value); 154 addDescriptionOf(_value);
149 155
150 Description describeMismatch(item, Description mismatchDescription, 156 Description describeMismatch(item, Description mismatchDescription,
151 MatchState matchState, bool verbose) { 157 MatchState matchState, bool verbose) {
152 if (item is !num) { 158 if (item is !num) {
153 return mismatchDescription.add(' not numeric'); 159 return mismatchDescription.add(' not numeric');
154 } else { 160 } else {
155 var diff = item - _value; 161 var diff = item - _value;
156 if (diff < 0) diff = -diff; 162 if (diff < 0) diff = -diff;
157 return mismatchDescription. 163 return mismatchDescription.
158 add(' differed by '). 164 add(' differs by ').
159 addDescriptionOf(diff); 165 addDescriptionOf(diff);
160 } 166 }
161 } 167 }
162 } 168 }
163 169
164 /** 170 /**
165 * Returns a matcher which matches if the match argument is greater 171 * Returns a matcher which matches if the match argument is greater
166 * than or equal to [low] and less than or equal to [high]. 172 * than or equal to [low] and less than or equal to [high].
167 */ 173 */
168 Matcher inInclusiveRange(low, high) => new _InRange(low, high, true, true); 174 Matcher inInclusiveRange(low, high) => new _InRange(low, high, true, true);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return mismatchDescription. 225 return mismatchDescription.
220 addDescriptionOf(item). 226 addDescriptionOf(item).
221 add(' not numeric'); 227 add(' not numeric');
222 } else { 228 } else {
223 return super.describeMismatch(item, mismatchDescription, 229 return super.describeMismatch(item, mismatchDescription,
224 matchState, verbose); 230 matchState, verbose);
225 } 231 }
226 } 232 }
227 } 233 }
228 234
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698