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

Side by Side Diff: pkg/unittest/lib/mock.dart

Issue 18442002: Add missing newline after Actual value in fail message. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « pkg/unittest/lib/matcher.dart ('k') | pkg/unittest/lib/src/basematcher.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 * A simple mocking/spy library. 6 * A simple mocking/spy library.
7 * 7 *
8 * ## Installing ## 8 * ## Installing ##
9 * 9 *
10 * Use [pub][] to install this package. Add the following to your `pubspec.yaml` 10 * Use [pub][] to install this package. Add the following to your `pubspec.yaml`
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 int distance: 1, 988 int distance: 1,
989 bool includeKeys: false}) => 989 bool includeKeys: false}) =>
990 _neighboring(false, keys, mockNameFilter, logFilter, 990 _neighboring(false, keys, mockNameFilter, logFilter,
991 distance, includeKeys); 991 distance, includeKeys);
992 } 992 }
993 993
994 /** 994 /**
995 * [_TimesMatcher]s are used to make assertions about the number of 995 * [_TimesMatcher]s are used to make assertions about the number of
996 * times a method was called. 996 * times a method was called.
997 */ 997 */
998 class _TimesMatcher extends BaseMatcher { 998 class _TimesMatcher extends Matcher {
999 final int min, max; 999 final int min, max;
1000 1000
1001 const _TimesMatcher(this.min, [this.max = -1]); 1001 const _TimesMatcher(this.min, [this.max = -1]);
1002 1002
1003 bool matches(logList, Map matchState) => logList.length >= min && 1003 bool matches(logList, Map matchState) => logList.length >= min &&
1004 (max < 0 || logList.length <= max); 1004 (max < 0 || logList.length <= max);
1005 1005
1006 Description describe(Description description) { 1006 Description describe(Description description) {
1007 description.add('to be called '); 1007 description.add('to be called ');
1008 if (max < 0) { 1008 if (max < 0) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 /** [happenedAtLeastOnce] matches one or more calls. */ 1046 /** [happenedAtLeastOnce] matches one or more calls. */
1047 const Matcher happenedAtLeastOnce = const _TimesMatcher(1); 1047 const Matcher happenedAtLeastOnce = const _TimesMatcher(1);
1048 1048
1049 /** [happenedAtMostOnce] matches zero or one call. */ 1049 /** [happenedAtMostOnce] matches zero or one call. */
1050 const Matcher happenedAtMostOnce = const _TimesMatcher(0, 1); 1050 const Matcher happenedAtMostOnce = const _TimesMatcher(0, 1);
1051 1051
1052 /** 1052 /**
1053 * [_ResultMatcher]s are used to make assertions about the results 1053 * [_ResultMatcher]s are used to make assertions about the results
1054 * of method calls. These can be used as optional parameters to [getLogs]. 1054 * of method calls. These can be used as optional parameters to [getLogs].
1055 */ 1055 */
1056 class _ResultMatcher extends BaseMatcher { 1056 class _ResultMatcher extends Matcher {
1057 final Action action; 1057 final Action action;
1058 final Matcher value; 1058 final Matcher value;
1059 1059
1060 const _ResultMatcher(this.action, this.value); 1060 const _ResultMatcher(this.action, this.value);
1061 1061
1062 bool matches(item, Map matchState) { 1062 bool matches(item, Map matchState) {
1063 if (item is! LogEntry) { 1063 if (item is! LogEntry) {
1064 return false; 1064 return false;
1065 } 1065 }
1066 // normalize the action; _PROXY is like _RETURN. 1066 // normalize the action; _PROXY is like _RETURN.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 /** 1125 /**
1126 * [_ResultSetMatcher]s are used to make assertions about the results 1126 * [_ResultSetMatcher]s are used to make assertions about the results
1127 * of method calls. When filtering an execution log by calling 1127 * of method calls. When filtering an execution log by calling
1128 * [getLogs], a [LogEntrySet] of matching call logs is returned; 1128 * [getLogs], a [LogEntrySet] of matching call logs is returned;
1129 * [_ResultSetMatcher]s can then assert various things about this 1129 * [_ResultSetMatcher]s can then assert various things about this
1130 * (sub)set of logs. 1130 * (sub)set of logs.
1131 * 1131 *
1132 * We could make this class use _ResultMatcher but it doesn't buy that 1132 * We could make this class use _ResultMatcher but it doesn't buy that
1133 * match and adds some perf hit, so there is some duplication here. 1133 * match and adds some perf hit, so there is some duplication here.
1134 */ 1134 */
1135 class _ResultSetMatcher extends BaseMatcher { 1135 class _ResultSetMatcher extends Matcher {
1136 final Action action; 1136 final Action action;
1137 final Matcher value; 1137 final Matcher value;
1138 final _Frequency frequency; // ALL, SOME, or NONE. 1138 final _Frequency frequency; // ALL, SOME, or NONE.
1139 1139
1140 const _ResultSetMatcher(this.action, this.value, this.frequency); 1140 const _ResultSetMatcher(this.action, this.value, this.frequency);
1141 1141
1142 bool matches(logList, Map matchState) { 1142 bool matches(logList, Map matchState) {
1143 for (LogEntry entry in logList) { 1143 for (LogEntry entry in logList) {
1144 // normalize the action; PROXY is like RETURN. 1144 // normalize the action; PROXY is like RETURN.
1145 Action eaction = entry.action; 1145 Action eaction = entry.action;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 } 1538 }
1539 } 1539 }
1540 } 1540 }
1541 1541
1542 /** Clear both logs and behavior. */ 1542 /** Clear both logs and behavior. */
1543 void reset() { 1543 void reset() {
1544 resetBehavior(); 1544 resetBehavior();
1545 clearLogs(); 1545 clearLogs();
1546 } 1546 }
1547 } 1547 }
OLDNEW
« no previous file with comments | « pkg/unittest/lib/matcher.dart ('k') | pkg/unittest/lib/src/basematcher.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698