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

Unified Diff: lib/unittest/mock.dart

Issue 10702177: Fix the weird names that can occur in exceptions and logs when there is no (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 | « lib/unittest/interfaces.dart ('k') | tests/lib/unittest/unittest_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/mock.dart
===================================================================
--- lib/unittest/mock.dart (revision 9575)
+++ lib/unittest/mock.dart (working copy)
@@ -138,6 +138,11 @@
String toString() {
Description d = new StringDescription();
d.addDescriptionOf(nameFilter);
+ // If the nameFilter was a simple string - i.e. just a method name -
+ // strip the quotes to make this more natural in appearance.
+ if (d.toString()[0] == "'") {
+ d.replace(d.toString().substring(1, d.toString().length - 1));
+ }
d.add('(');
for (var i = 0; i < argMatchers.length; i++) {
if (i > 0) d.add(', ');
@@ -316,7 +321,7 @@
/** Utility function for optionally qualified method names */
String _qualifiedName(owner, String method) {
- if (owner == null) {
+ if (owner == null || owner === anything) {
return method;
} else if (owner is Matcher) {
Description d = new StringDescription();
@@ -348,8 +353,8 @@
* Create a new [LogEntryList] consisting of [LogEntry]s from
* this list that match the specified [mockNameFilter] and [logFilter].
* [mockNameFilter] can be null, a [String], a predicate [Function],
- * or a [Matcher]. If [mockNameFilter] is null, only Mocks with no name
- * will be checked.
+ * or a [Matcher]. If [mockNameFilter] is null, this is the same as
+ * [anything].
* 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.
@@ -358,7 +363,11 @@
CallMatcher logFilter,
Matcher actionMatcher,
bool destructive = false]) {
- mockNameFilter = wrapMatcher(mockNameFilter);
+ if (mockNameFilter == null) {
+ mockNameFilter = anything;
+ } else {
+ mockNameFilter = wrapMatcher(mockNameFilter);
+ }
if (logFilter == null) {
logFilter = new CallMatcher();
}
@@ -769,6 +778,9 @@
this.log,
throwIfNoBehavior = false,
enableLogging = true]) : _throwIfNoBehavior = throwIfNoBehavior {
+ if (log != null && name == null) {
+ throw new Exception("Mocks with shared logs must have a name.");
+ }
logging = enableLogging;
_behaviors = new Map<String,Behavior>();
}
« no previous file with comments | « lib/unittest/interfaces.dart ('k') | tests/lib/unittest/unittest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698