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

Side by Side Diff: pkg/unittest/lib/src/description.dart

Issue 210413002: pkg/unittest: using matcher and mock from packages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: releasing v0.10.1 Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/lib/src/expect.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of unittest.matcher;
6
7 /**
8 * The default implementation of IDescription. This should rarely need
9 * substitution, although conceivably it is a place where other languages
10 * could be supported.
11 */
12 class StringDescription implements Description {
13 var _out;
14
15 /** Initialize the description with initial contents [init]. */
16 StringDescription([String init = '']) {
17 _out = init;
18 }
19
20 int get length => _out.length;
21
22 /** Get the description as a string. */
23 String toString() => _out;
24
25 /** Append [text] to the description. */
26 Description add(text) {
27 _out = '${_out}${text}';
28 return this;
29 }
30
31 /** Change the value of the description. */
32 Description replace(String text) {
33 _out = text;
34 return this;
35 }
36
37 /**
38 * Appends a description of [value]. If it is an IMatcher use its
39 * describe method; if it is a string use its literal value after
40 * escaping any embedded control characters; otherwise use its
41 * toString() value and wrap it in angular "quotes".
42 */
43 Description addDescriptionOf(value) {
44 if (value is Matcher) {
45 value.describe(this);
46 } else {
47 add(prettyPrint(value, maxLineLength: 80, maxItems: 25));
48 }
49 return this;
50 }
51
52 /**
53 * Append an [Iterable] [list] of objects to the description, using the
54 * specified [separator] and framing the list with [start]
55 * and [end].
56 */
57 Description addAll(String start, String separator, String end,
58 Iterable list) {
59 var separate = false;
60 add(start);
61 for (var item in list) {
62 if (separate) {
63 add(separator);
64 }
65 addDescriptionOf(item);
66 separate = true;
67 }
68 add(end);
69 return this;
70 }
71
72 /** Escape the control characters in [string] so that they are visible. */
73 _addEscapedString(String string) {
74 add("'");
75 add(escapeString(string));
76 add("'");
77 }
78 }
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/lib/src/expect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698