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

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

Issue 12207123: Improve matcher descriptions that match against objects, and thus fix a bug (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/unittest/test/mock_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of matcher; 5 part of matcher;
6 6
7 /** 7 /**
8 * The default implementation of IDescription. This should rarely need 8 * The default implementation of IDescription. This should rarely need
9 * substitution, although conceivably it is a place where other languages 9 * substitution, although conceivably it is a place where other languages
10 * could be supported. 10 * could be supported.
(...skipping 29 matching lines...) Expand all
40 */ 40 */
41 Description addDescriptionOf(value) { 41 Description addDescriptionOf(value) {
42 if (value is Matcher) { 42 if (value is Matcher) {
43 value.describe(this); 43 value.describe(this);
44 } else if (value is String) { 44 } else if (value is String) {
45 _addEscapedString(value); 45 _addEscapedString(value);
46 } else { 46 } else {
47 String description = (value == null) ? "null" : value.toString(); 47 String description = (value == null) ? "null" : value.toString();
48 if (description.startsWith('<') && description.endsWith('>')) { 48 if (description.startsWith('<') && description.endsWith('>')) {
49 add(description); 49 add(description);
50 } else if (description.startsWith("Instance of")) {
51 add('<');
52 add(description);
53 add(':');
54 add(value.hashCode.toString());
55 add('>');
50 } else { 56 } else {
51 add('<'); 57 add('<');
52 add(description); 58 add(description);
53 add('>'); 59 add('>');
54 } 60 }
55 } 61 }
56 return this; 62 return this;
57 } 63 }
58 64
59 /** 65 /**
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 else if (ch == '\n') 98 else if (ch == '\n')
93 return '\\n'; 99 return '\\n';
94 else if (ch == '\r') 100 else if (ch == '\r')
95 return '\\r'; 101 return '\\r';
96 else if (ch == '\t') 102 else if (ch == '\t')
97 return '\\t'; 103 return '\\t';
98 else 104 else
99 return ch; 105 return ch;
100 } 106 }
101 } 107 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/test/mock_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698