Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 ErrorFormatter _assertErrorFormatter = null; | 134 ErrorFormatter _assertErrorFormatter = null; |
| 135 | 135 |
| 136 // The default error formatter implementation. | 136 // The default error formatter implementation. |
| 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: ') | |
| 145 .add(mismatchDescription.toString()).add('.\n'); | |
| 146 | 144 |
| 147 description.add('Actual: ').addDescriptionOf(actual); | 145 description.add(' Actual: ').addDescriptionOf(actual); |
| 146 var info = mismatchDescription.toString(); | |
| 147 if (info.length > 0) { | |
|
Siggi Cherem (dart-lang)
2013/06/12 00:34:45
how about use mismatchDescription.length here?
gram
2013/06/13 19:06:15
Done.
| |
| 148 description.add(' Which: ${info}\n'); | |
|
Siggi Cherem (dart-lang)
2013/06/12 00:34:45
then this can simply be $mispatchDescription
Siggi Cherem (dart-lang)
2013/06/12 00:34:45
" Which:" => " Reason:" ?
gram
2013/06/13 19:06:15
Done.
gram
2013/06/13 19:06:15
"Which" scans better IMO.
| |
| 149 } | |
| 148 if (reason != null) { | 150 if (reason != null) { |
| 149 description.add(reason).add('\n'); | 151 description.add(reason).add('\n'); |
| 150 } | 152 } |
| 151 return description.toString(); | 153 return description.toString(); |
| 152 } | 154 } |
| 153 | 155 |
| 154 /** | 156 /** |
| 155 * Changes or resets to default the failure message formatter for expect(). | 157 * Changes or resets to default the failure message formatter for expect(). |
| 156 * [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 |
| 157 * 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 |
| 158 * formatter is returned; this allows custom expect handlers to easily | 160 * formatter is returned; this allows custom expect handlers to easily |
| 159 * get a reference to the default formatter. | 161 * get a reference to the default formatter. |
| 160 */ | 162 */ |
| 161 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { | 163 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { |
| 162 if (formatter == null) { | 164 if (formatter == null) { |
| 163 formatter = _defaultErrorFormatter; | 165 formatter = _defaultErrorFormatter; |
| 164 } | 166 } |
| 165 return _assertErrorFormatter = formatter; | 167 return _assertErrorFormatter = formatter; |
| 166 } | 168 } |
| 167 | 169 |
| OLD | NEW |