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

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

Issue 14600029: Add pretty-printing to unittest and more thoroughly print values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. 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 /** 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 Description describe(Description description) => 144 Description describe(Description description) =>
145 description.add('a numeric value within '). 145 description.add('a numeric value within ').
146 addDescriptionOf(_delta). 146 addDescriptionOf(_delta).
147 add(' of '). 147 add(' of ').
148 addDescriptionOf(_value); 148 addDescriptionOf(_value);
149 149
150 Description describeMismatch(item, Description mismatchDescription, 150 Description describeMismatch(item, Description mismatchDescription,
151 MatchState matchState, bool verbose) { 151 MatchState matchState, bool verbose) {
152 if (item is !num) { 152 if (item is !num) {
153 return mismatchDescription. 153 return mismatchDescription.add(' not numeric');
154 addDescriptionOf(item).
155 add(' not numeric');
156 } else { 154 } else {
157 var diff = item - _value; 155 var diff = item - _value;
158 if (diff < 0) diff = -diff; 156 if (diff < 0) diff = -diff;
159 return mismatchDescription. 157 return mismatchDescription.
160 addDescriptionOf(item).
161 add(' differed by '). 158 add(' differed by ').
162 addDescriptionOf(diff); 159 addDescriptionOf(diff);
163 } 160 }
164 } 161 }
165 } 162 }
166 163
167 /** 164 /**
168 * Returns a matcher which matches if the match argument is greater 165 * Returns a matcher which matches if the match argument is greater
169 * than or equal to [low] and less than or equal to [high]. 166 * than or equal to [low] and less than or equal to [high].
170 */ 167 */
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return mismatchDescription. 219 return mismatchDescription.
223 addDescriptionOf(item). 220 addDescriptionOf(item).
224 add(' not numeric'); 221 add(' not numeric');
225 } else { 222 } else {
226 return super.describeMismatch(item, mismatchDescription, 223 return super.describeMismatch(item, mismatchDescription,
227 matchState, verbose); 224 matchState, verbose);
228 } 225 }
229 } 226 }
230 } 227 }
231 228
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698