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

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

Issue 317733006: pkg/matcher: reapply 36881,36896 working around Issue 19173 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nit Created 6 years, 6 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 | « pkg/matcher/lib/src/core_matchers.dart ('k') | pkg/matcher/lib/src/error_matchers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/matcher/lib/src/description.dart
diff --git a/pkg/matcher/lib/src/description.dart b/pkg/matcher/lib/src/description.dart
index f8ebf09d7d0b072ab9e0c4ea761d4689249f70ac..f03934d0bfd494c890291742f3495b34c05f0ba9 100644
--- a/pkg/matcher/lib/src/description.dart
+++ b/pkg/matcher/lib/src/description.dart
@@ -6,44 +6,39 @@ library matcher.description;
import 'interfaces.dart';
import 'pretty_print.dart';
-import 'utils.dart';
-/**
- * The default implementation of IDescription. This should rarely need
- * substitution, although conceivably it is a place where other languages
- * could be supported.
- */
+/// The default implementation of [Description]. This should rarely need
+/// substitution, although conceivably it is a place where other languages
+/// could be supported.
class StringDescription implements Description {
- var _out;
+ final StringBuffer _out = new StringBuffer();
- /** Initialize the description with initial contents [init]. */
+ /// Initialize the description with initial contents [init].
StringDescription([String init = '']) {
- _out = init;
+ _out.write(init);
}
int get length => _out.length;
- /** Get the description as a string. */
- String toString() => _out;
+ /// Get the description as a string.
+ String toString() => _out.toString();
- /** Append [text] to the description. */
- Description add(text) {
- _out = '${_out}${text}';
+ /// Append [text] to the description.
+ Description add(String text) {
+ _out.write(text);
return this;
}
- /** Change the value of the description. */
+ /// Change the value of the description.
Description replace(String text) {
- _out = text;
- return this;
+ _out.clear();
+ return add(text);
}
- /**
- * Appends a description of [value]. If it is an IMatcher use its
- * describe method; if it is a string use its literal value after
- * escaping any embedded control characters; otherwise use its
- * toString() value and wrap it in angular "quotes".
- */
+ /// Appends a description of [value]. If it is an IMatcher use its
+ /// describe method; if it is a string use its literal value after
+ /// escaping any embedded control characters; otherwise use its
+ /// toString() value and wrap it in angular "quotes".
Description addDescriptionOf(value) {
if (value is Matcher) {
value.describe(this);
@@ -53,11 +48,9 @@ class StringDescription implements Description {
return this;
}
- /**
- * Append an [Iterable] [list] of objects to the description, using the
- * specified [separator] and framing the list with [start]
- * and [end].
- */
+ /// Append an [Iterable] [list] of objects to the description, using the
+ /// specified [separator] and framing the list with [start]
+ /// and [end].
Description addAll(String start, String separator, String end,
Iterable list) {
var separate = false;
@@ -72,11 +65,4 @@ class StringDescription implements Description {
add(end);
return this;
}
-
- /** Escape the control characters in [string] so that they are visible. */
- _addEscapedString(String string) {
- add("'");
- add(escapeString(string));
- add("'");
- }
}
« no previous file with comments | « pkg/matcher/lib/src/core_matchers.dart ('k') | pkg/matcher/lib/src/error_matchers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698