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

Unified Diff: lib/src/core_matchers.dart

Issue 891463004: Correctly match and print strings with escaped values (Closed) Base URL: https://github.com/dart-lang/matcher.git@master
Patch Set: nits Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/pretty_print.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/core_matchers.dart
diff --git a/lib/src/core_matchers.dart b/lib/src/core_matchers.dart
index abecb769856fa31f053c2a0202c904948d5f30e9..a3d1f5750dcfeea6736b26a4b8073a82ee31de0a 100644
--- a/lib/src/core_matchers.dart
+++ b/lib/src/core_matchers.dart
@@ -297,8 +297,8 @@ class _StringEqualsMatcher extends Matcher {
} else {
var buff = new StringBuffer();
buff.write('is different.');
- var escapedItem = _escape(item);
- var escapedValue = _escape(_value);
+ var escapedItem = escape(item);
+ var escapedValue = escape(_value);
int minLength = escapedItem.length < escapedValue.length
? escapedItem.length
: escapedValue.length;
@@ -334,9 +334,6 @@ class _StringEqualsMatcher extends Matcher {
}
}
- static String _escape(String s) =>
- s.replaceAll('\n', '\\n').replaceAll('\r', '\\r').replaceAll('\t', '\\t');
-
static void _writeLeading(StringBuffer buff, String s, int start) {
if (start > 10) {
buff.write('... ');
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/pretty_print.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698