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

Unified Diff: lib/src/pretty_print.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 | « lib/src/core_matchers.dart ('k') | lib/src/util.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/pretty_print.dart
diff --git a/lib/src/pretty_print.dart b/lib/src/pretty_print.dart
index df93dbb013fe3af7a815c19e17529e280a4343ce..c20102be09715db1d6381eb2c2a47c36552b5ddd 100644
--- a/lib/src/pretty_print.dart
+++ b/lib/src/pretty_print.dart
@@ -6,6 +6,7 @@ library matcher.pretty_print;
import 'description.dart';
import 'interfaces.dart';
+import 'util.dart';
/// Returns a pretty-printed representation of [object].
///
@@ -132,21 +133,4 @@ String _typeName(x) {
///
/// This doesn't add quotes to the string, but it does escape single quote
/// characters so that single quotes can be applied externally.
-String _escapeString(String source) =>
- source.split("").map(_escapeChar).join("");
-
-/// Return the escaped form of a character [ch].
-String _escapeChar(String ch) {
- switch (ch) {
- case "'":
- return "\\'";
- case '\n':
- return '\\n';
- case '\r':
- return '\\r';
- case '\t':
- return '\\t';
- default:
- return ch;
- }
-}
+String _escapeString(String source) => escape(source).replaceAll("'", r"\'");
« no previous file with comments | « lib/src/core_matchers.dart ('k') | lib/src/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698