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

Side by Side Diff: lib/unittest/expect.dart

Issue 10694146: Added ability to disable logging in mocks, to avoid the memory overhead if you don't need behavior … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 | « lib/unittest/core_matchers.dart ('k') | lib/unittest/mock.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 /** 5 /**
6 * This is the main assertion function. It asserts that [actual] 6 * This is the main assertion function. It asserts that [actual]
7 * matches the [matcher]. [matcher] is optional and defaults to isTrue, 7 * matches the [matcher]. [matcher] is optional and defaults to isTrue,
8 * so expect can be used with a single predicate argument. [reason] 8 * so expect can be used with a single predicate argument. [reason]
9 * is optional and is typically not supplied if a reasonable matcher is 9 * is optional and is typically not supplied if a reasonable matcher is
10 * explicitly provided, as a reason can be generated from the matcher. 10 * explicitly provided, as a reason can be generated from the matcher.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 // The error message formatter for failed asserts. 106 // The error message formatter for failed asserts.
107 ErrorFormatter _assertErrorFormatter = null; 107 ErrorFormatter _assertErrorFormatter = null;
108 108
109 // The default error formatter implementation. 109 // The default error formatter implementation.
110 String _defaultErrorFormatter(actual, Matcher matcher, String reason) { 110 String _defaultErrorFormatter(actual, Matcher matcher, String reason) {
111 var description = new StringDescription(); 111 var description = new StringDescription();
112 description.add('Expected: ').addDescriptionOf(matcher). 112 description.add('Expected: ').addDescriptionOf(matcher).
113 add('\n but: '); 113 add('\n but: ');
114 matcher.describeMismatch(actual, description); 114 matcher.describeMismatch(actual, description);
115 description.add('.\n');
115 if (reason != null) { 116 if (reason != null) {
116 description.add('\n').add(reason).add('\n'); 117 description.add(reason).add('\n');
117 } 118 }
118 return description.toString(); 119 return description.toString();
119 } 120 }
120 121
121 /** 122 /**
122 * Changes or resets to default the failure message formatter for expect(). 123 * Changes or resets to default the failure message formatter for expect().
123 * [formatter] is a reference to the new formatter; if this is omitted or 124 * [formatter] is a reference to the new formatter; if this is omitted or
124 * null then the failure formatter is reset to the default. The new 125 * null then the failure formatter is reset to the default. The new
125 * formatter is returned; this allows custom expect handlers to easily 126 * formatter is returned; this allows custom expect handlers to easily
126 * get a reference to the default formatter. 127 * get a reference to the default formatter.
127 */ 128 */
128 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) { 129 ErrorFormatter configureExpectFormatter([ErrorFormatter formatter = null]) {
129 if (formatter == null) { 130 if (formatter == null) {
130 formatter = _defaultErrorFormatter; 131 formatter = _defaultErrorFormatter;
131 } 132 }
132 return _assertErrorFormatter = formatter; 133 return _assertErrorFormatter = formatter;
133 } 134 }
134 135
OLDNEW
« no previous file with comments | « lib/unittest/core_matchers.dart ('k') | lib/unittest/mock.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698