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

Unified Diff: pkg/mock/lib/src/mock.dart

Issue 278613003: pkg/mock: fixes for v0.11 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: status file fix for mismatched version constraints Created 6 years, 7 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 | « pkg/mock/lib/src/log_entry_list.dart ('k') | pkg/mock/lib/src/result_matcher.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mock/lib/src/mock.dart
diff --git a/pkg/mock/lib/src/mock.dart b/pkg/mock/lib/src/mock.dart
index 29598b83915e1c752d24bcf4185551247ed75a50..bdbb8f3d4f831e7eadface56f5ec564a7a68fc84 100644
--- a/pkg/mock/lib/src/mock.dart
+++ b/pkg/mock/lib/src/mock.dart
@@ -25,7 +25,7 @@ class Mock {
final String name;
/** The set of [Behavior]s supported. */
- final LinkedHashMap<String,Behavior> _behaviors;
+ final LinkedHashMap<String, Behavior> _behaviors;
/** How to handle unknown method calls - swallow or throw. */
final bool _throwIfNoBehavior;
@@ -85,8 +85,8 @@ class Mock {
* later.
*/
Mock.spy(this._realObject, {this.name, this.log})
- : _behaviors = null,
- _throwIfNoBehavior = true {
+ : _behaviors = null,
+ _throwIfNoBehavior = true {
logging = true;
}
@@ -125,7 +125,7 @@ class Mock {
} else if (invocation.isSetter) {
method = 'set $method';
// Remove the trailing '='.
- if (method[method.length-1] == '=') {
+ if (method[method.length - 1] == '=') {
method = method.substring(0, method.length - 1);
}
}
@@ -175,54 +175,9 @@ class Mock {
}
throw value;
} else if (action == Action.PROXY) {
- // TODO(gram): Replace all this with:
- // var rtn = reflect(value).apply(invocation.positionalArguments,
- // invocation.namedArguments);
- // once that is supported.
- var rtn;
- switch (args.length) {
- case 0:
- rtn = value();
- break;
- case 1:
- rtn = value(args[0]);
- break;
- case 2:
- rtn = value(args[0], args[1]);
- break;
- case 3:
- rtn = value(args[0], args[1], args[2]);
- break;
- case 4:
- rtn = value(args[0], args[1], args[2], args[3]);
- break;
- case 5:
- rtn = value(args[0], args[1], args[2], args[3], args[4]);
- break;
- case 6:
- rtn = value(args[0], args[1], args[2], args[3],
- args[4], args[5]);
- break;
- case 7:
- rtn = value(args[0], args[1], args[2], args[3],
- args[4], args[5], args[6]);
- break;
- case 8:
- rtn = value(args[0], args[1], args[2], args[3],
- args[4], args[5], args[6], args[7]);
- break;
- case 9:
- rtn = value(args[0], args[1], args[2], args[3],
- args[4], args[5], args[6], args[7], args[8]);
- break;
- case 9:
- rtn = value(args[0], args[1], args[2], args[3],
- args[4], args[5], args[6], args[7], args[8], args[9]);
- break;
- default:
- throw new Exception(
- "Cannot proxy calls with more than 10 parameters.");
- }
+ var mir = reflect(value) as ClosureMirror;
+ var rtn = mir.invoke(#call, invocation.positionalArguments,
+ invocation.namedArguments).reflectee;
if (_logging && b.logging) {
log.add(new LogEntry(name, method, args, action, rtn));
}
« no previous file with comments | « pkg/mock/lib/src/log_entry_list.dart ('k') | pkg/mock/lib/src/result_matcher.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698