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 library matcher.core_matchers; | 5 library matcher.core_matchers; |
6 | 6 |
7 import 'description.dart'; | 7 import 'description.dart'; |
8 import 'interfaces.dart'; | 8 import 'interfaces.dart'; |
9 import 'util.dart'; | 9 import 'util.dart'; |
10 | 10 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 if (item is! String) { | 295 if (item is! String) { |
296 return mismatchDescription.addDescriptionOf(item).add('is not a string'); | 296 return mismatchDescription.addDescriptionOf(item).add('is not a string'); |
297 } else { | 297 } else { |
298 var buff = new StringBuffer(); | 298 var buff = new StringBuffer(); |
299 buff.write('is different.'); | 299 buff.write('is different.'); |
300 var escapedItem = escape(item); | 300 var escapedItem = escape(item); |
301 var escapedValue = escape(_value); | 301 var escapedValue = escape(_value); |
302 int minLength = escapedItem.length < escapedValue.length | 302 int minLength = escapedItem.length < escapedValue.length |
303 ? escapedItem.length | 303 ? escapedItem.length |
304 : escapedValue.length; | 304 : escapedValue.length; |
305 int start; | 305 int start = 0; |
nweiz
2015/02/19 20:46:41
While you're in here, change this to "var".
kevmoo
2015/02/23 23:21:56
Done.
| |
306 for (start = 0; start < minLength; start++) { | 306 for (; start < minLength; start++) { |
307 if (escapedValue.codeUnitAt(start) != escapedItem.codeUnitAt(start)) { | 307 if (escapedValue.codeUnitAt(start) != escapedItem.codeUnitAt(start)) { |
308 break; | 308 break; |
309 } | 309 } |
310 } | 310 } |
311 if (start == minLength) { | 311 if (start == minLength) { |
312 if (escapedValue.length < escapedItem.length) { | 312 if (escapedValue.length < escapedItem.length) { |
313 buff.write(' Both strings start the same, but the given value also' | 313 buff.write(' Both strings start the same, but the given value also' |
314 ' has the following trailing characters: '); | 314 ' has the following trailing characters: '); |
315 _writeTrailing(buff, escapedItem, escapedValue.length); | 315 _writeTrailing(buff, escapedItem, escapedValue.length); |
316 } else { | 316 } else { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 .addDescriptionOf(matchState['feature']); | 644 .addDescriptionOf(matchState['feature']); |
645 var innerDescription = new StringDescription(); | 645 var innerDescription = new StringDescription(); |
646 _matcher.describeMismatch( | 646 _matcher.describeMismatch( |
647 matchState['feature'], innerDescription, matchState['state'], verbose); | 647 matchState['feature'], innerDescription, matchState['state'], verbose); |
648 if (innerDescription.length > 0) { | 648 if (innerDescription.length > 0) { |
649 mismatchDescription.add(' which ').add(innerDescription.toString()); | 649 mismatchDescription.add(' which ').add(innerDescription.toString()); |
650 } | 650 } |
651 return mismatchDescription; | 651 return mismatchDescription; |
652 } | 652 } |
653 } | 653 } |
OLD | NEW |