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

Unified Diff: pkg/unittest/lib/src/description.dart

Issue 14600029: Add pretty-printing to unittest and more thoroughly print values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 7 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
Index: pkg/unittest/lib/src/description.dart
diff --git a/pkg/unittest/lib/src/description.dart b/pkg/unittest/lib/src/description.dart
index cdd819348914e70c4434350c48a5c296385d1951..cde5243ef175f7731ee5c025243182e4d6a07262 100644
--- a/pkg/unittest/lib/src/description.dart
+++ b/pkg/unittest/lib/src/description.dart
@@ -41,23 +41,8 @@ class StringDescription implements Description {
Description addDescriptionOf(value) {
if (value is Matcher) {
value.describe(this);
- } else if (value is String) {
- _addEscapedString(value);
} else {
- String description = (value == null) ? "null" : value.toString();
- if (description.startsWith('<') && description.endsWith('>')) {
- add(description);
- } else if (description.startsWith("Instance of")) {
- add('<');
- add(description);
- add(':');
- add(value.hashCode.toString());
- add('>');
- } else {
- add('<');
- add(description);
- add('>');
- }
+ add(prettyPrint(value, maxLineLength: 80, maxItems: 25));
}
return this;
}
@@ -85,23 +70,7 @@ class StringDescription implements Description {
/** Escape the control characters in [string] so that they are visible. */
_addEscapedString(String string) {
add("'");
- for (var i = 0; i < string.length; i++) {
- add(_escape(string[i]));
- }
+ add(escapeString(string));
add("'");
}
-
- /** Return the escaped form of a character [ch]. */
- _escape(ch) {
- if (ch == "'")
- return "\'";
- else if (ch == '\n')
- return '\\n';
- else if (ch == '\r')
- return '\\r';
- else if (ch == '\t')
- return '\\t';
- else
- return ch;
- }
}

Powered by Google App Engine
This is Rietveld 408576698