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); |
} |
} |