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 unittest.matcher; | 5 part of unittest.matcher; |
6 | 6 |
7 /** | 7 /** |
8 * Returns a matcher that matches empty strings, maps or iterables | 8 * Returns a matcher that matches empty strings, maps or iterables |
9 * (including collections). | 9 * (including collections). |
10 */ | 10 */ |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 buff.write('^\n Differ at offset $start'); | 293 buff.write('^\n Differ at offset $start'); |
294 } | 294 } |
295 | 295 |
296 return mismatchDescription.replace(buff.toString()); | 296 return mismatchDescription.replace(buff.toString()); |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 static String _escape(String s) => | 300 static String _escape(String s) => |
301 s.replaceAll('\n', '\\n').replaceAll('\r', '\\r').replaceAll('\t', '\\t'); | 301 s.replaceAll('\n', '\\n').replaceAll('\r', '\\r').replaceAll('\t', '\\t'); |
302 | 302 |
303 static String _writeLeading(StringBuffer buff, String s, int start) { | 303 static void _writeLeading(StringBuffer buff, String s, int start) { |
304 if (start > 10) { | 304 if (start > 10) { |
305 buff.write('... '); | 305 buff.write('... '); |
306 buff.write(s.substring(start - 10, start)); | 306 buff.write(s.substring(start - 10, start)); |
307 } else { | 307 } else { |
308 buff.write(s.substring(0, start)); | 308 buff.write(s.substring(0, start)); |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 static String _writeTrailing(StringBuffer buff, String s, int start) { | 312 static void _writeTrailing(StringBuffer buff, String s, int start) { |
313 if (start + 10 > s.length) { | 313 if (start + 10 > s.length) { |
314 buff.write(s.substring(start)); | 314 buff.write(s.substring(start)); |
315 } else { | 315 } else { |
316 buff.write(s.substring(start, start + 10)); | 316 buff.write(s.substring(start, start + 10)); |
317 buff.write(' ...'); | 317 buff.write(' ...'); |
318 } | 318 } |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 /** A matcher that matches any value. */ | 322 /** A matcher that matches any value. */ |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 addDescriptionOf(matchState['feature']); | 885 addDescriptionOf(matchState['feature']); |
886 var innerDescription = new StringDescription(); | 886 var innerDescription = new StringDescription(); |
887 _matcher.describeMismatch(matchState['feature'], innerDescription, | 887 _matcher.describeMismatch(matchState['feature'], innerDescription, |
888 matchState['state'], verbose); | 888 matchState['state'], verbose); |
889 if (innerDescription.length > 0) { | 889 if (innerDescription.length > 0) { |
890 mismatchDescription.add(' which ').add(innerDescription.toString()); | 890 mismatchDescription.add(' which ').add(innerDescription.toString()); |
891 } | 891 } |
892 return mismatchDescription; | 892 return mismatchDescription; |
893 } | 893 } |
894 } | 894 } |
OLD | NEW |