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

Unified Diff: lib/unittest/mock.dart

Issue 10689148: CallMatchers can now be null, or take null for a method name. This might be (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/lib/unittest/unittest_test.dart » ('j') | tests/lib/unittest/unittest_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/mock.dart
===================================================================
--- lib/unittest/mock.dart (revision 9489)
+++ lib/unittest/mock.dart (working copy)
@@ -84,7 +84,7 @@
String name;
List<Matcher> argMatchers;
- CallMatcher(this.name, [
+ CallMatcher([this.name,
arg0 = _noArg,
arg1 = _noArg,
arg2 = _noArg,
@@ -126,7 +126,8 @@
*/
String toString() {
Description d = new StringDescription();
- d.add(name).add('(');
+ if (name != null) d.add(name);
+ d.add('(');
for (var i = 0; i < argMatchers.length; i++) {
if (i > 0) d.add(', ');
d.addDescriptionOf(argMatchers[i]);
@@ -140,7 +141,7 @@
* if it matches this [CallMatcher.
*/
bool matches(String method, List arguments) {
- if (method != this.name) {
+ if (this.name != null && method != this.name) {
return false;
}
if (arguments.length < argMatchers.length) {
@@ -156,17 +157,17 @@
}
/** [callsTo] returns a CallMatcher for the specified signature. */
-CallMatcher callsTo(String method, [
- arg0 = _noArg,
- arg1 = _noArg,
- arg2 = _noArg,
- arg3 = _noArg,
- arg4 = _noArg,
- arg5 = _noArg,
- arg6 = _noArg,
- arg7 = _noArg,
- arg8 = _noArg,
- arg9 = _noArg]) {
+CallMatcher callsTo([String method,
+ arg0 = _noArg,
+ arg1 = _noArg,
+ arg2 = _noArg,
+ arg3 = _noArg,
+ arg4 = _noArg,
+ arg5 = _noArg,
+ arg6 = _noArg,
+ arg7 = _noArg,
+ arg8 = _noArg,
+ arg9 = _noArg]) {
return new CallMatcher(method, arg0, arg1, arg2, arg3, arg4,
arg5, arg6, arg7, arg8, arg9);
}
@@ -325,13 +326,17 @@
/**
* Create a new [LogEntryList] consisting of [LogEntry]s from
* this list that match the specified [mockName] and [logFilter].
- * If [mockName] is null, all entries will be checked. If [destructive]
+ * If [mockName] is null, all entries will be checked. If [logFilter]
+ * is null, all entries in the log will be returned. If [destructive]
* is true, the log entries are removed from the original list.
*/
- LogEntryList getMatches(String mockName,
+ LogEntryList getMatches([String mockName,
CallMatcher logFilter,
- [Matcher actionMatcher,
+ Matcher actionMatcher,
bool destructive = false]) {
+ if (logFilter == null) {
+ logFilter = new CallMatcher();
+ }
String filterName = _qualifiedName(mockName, logFilter.toString());
LogEntryList rtn = new LogEntryList(filterName);
for (var i = 0; i < logs.length; i++) {
@@ -871,8 +876,9 @@
*
* getLogs(callsTo(...)).verify(...);
*/
- LogEntryList getLogs(CallMatcher logFilter, [Matcher actionMatcher,
- bool destructive = false]) {
+ LogEntryList getLogs([CallMatcher logFilter,
+ Matcher actionMatcher,
+ bool destructive = false]) {
return log.getMatches(name, logFilter, actionMatcher, destructive);
}
}
« no previous file with comments | « no previous file | tests/lib/unittest/unittest_test.dart » ('j') | tests/lib/unittest/unittest_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698