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

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

Issue 15755005: Change output of string equality match failures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 /** The objects thrown by the default failure handler. */ 7 /** The objects thrown by the default failure handler. */
8 class TestFailure { 8 class TestFailure {
9 String _message; 9 String _message;
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 String _defaultErrorFormatter(actual, Matcher matcher, String reason, 137 String _defaultErrorFormatter(actual, Matcher matcher, String reason,
138 MatchState matchState, bool verbose) { 138 MatchState matchState, bool verbose) {
139 var description = new StringDescription(); 139 var description = new StringDescription();
140 description.add('Expected: ').addDescriptionOf(matcher).add('\n'); 140 description.add('Expected: ').addDescriptionOf(matcher).add('\n');
141 141
142 var mismatchDescription = new StringDescription(); 142 var mismatchDescription = new StringDescription();
143 matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); 143 matcher.describeMismatch(actual, mismatchDescription, matchState, verbose);
144 description.add(' But: ') 144 description.add(' But: ')
145 .add(mismatchDescription.toString()).add('.\n'); 145 .add(mismatchDescription.toString()).add('.\n');
146 146
147 if (!mismatchDescription.toString().startsWith("was ")) { 147 if (matcher.includeActual(mismatchDescription)) {
148 description.add('Actual: ').addDescriptionOf(actual); 148 description.add('Actual: ').addDescriptionOf(actual);
149 } 149 }
150 if (reason != null) { 150 if (reason != null) {
151 description.add(reason).add('\n'); 151 description.add(reason).add('\n');
152 } 152 }
153 return description.toString(); 153 return description.toString();
154 } 154 }
155 155
156 /** 156 /**
157 * Changes or resets to default the failure message formatter for expect(). 157 * Changes or resets to default the failure message formatter for expect().
158 * [formatter] is a reference to the new formatter; if this is omitted or 158 * [formatter] is a reference to the new formatter; if this is omitted or
159 * null then the failure formatter is reset to the default. The new 159 * null then the failure formatter is reset to the default. The new
160 * formatter is returned; this allows custom expect handlers to easily 160 * formatter is returned; this allows custom expect handlers to easily
161 * get a reference to the default formatter. 161 * get a reference to the default formatter.
162 */ 162 */
163 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { 163 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) {
164 if (formatter == null) { 164 if (formatter == null) {
165 formatter = _defaultErrorFormatter; 165 formatter = _defaultErrorFormatter;
166 } 166 }
167 return _assertErrorFormatter = formatter; 167 return _assertErrorFormatter = formatter;
168 } 168 }
169 169
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698