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

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

Issue 11231074: Change signature of noSuchMethod to take an InvocationMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: One more test expectation Created 8 years, 1 month 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/pkg.status ('k') | runtime/lib/invocation_mirror_patch.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 part of unittest; 5 part of unittest;
6 6
7 /** 7 /**
8 * The error formatter for mocking is a bit different from the default one 8 * The error formatter for mocking is a bit different from the default one
9 * for unit testing; instead of the third argument being a 'reason' 9 * for unit testing; instead of the third argument being a 'reason'
10 * it is instead a [signature] describing the method signature filter 10 * it is instead a [signature] describing the method signature filter
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 } 1269 }
1270 } 1270 }
1271 1271
1272 /** 1272 /**
1273 * This is the handler for method calls. We loo through the list 1273 * This is the handler for method calls. We loo through the list
1274 * of [Behavior]s, and find the first match that still has return 1274 * of [Behavior]s, and find the first match that still has return
1275 * values available, and then do the action specified by that 1275 * values available, and then do the action specified by that
1276 * return value. If we find no [Behavior] to apply an exception is 1276 * return value. If we find no [Behavior] to apply an exception is
1277 * thrown. 1277 * thrown.
1278 */ 1278 */
1279 noSuchMethod(String method, List args) { 1279 noSuchMethod(InvocationMirror invocation) {
1280 if (method.startsWith('get:')) { 1280 String method = invocation.memberName;
1281 method = 'get ${method.substring(4)}'; 1281 // Remove this when InvocationMirror works correctly.
1282 if (method.startsWith("get:")) method = method.substring(4);
1283
1284 if (invocation.isGetter) {
1285 method = 'get $method';
1282 } 1286 }
1287 List args = invocation.positionalArguments;
1288 // TODO: Handle named arguments too.
1289
1283 bool matchedMethodName = false; 1290 bool matchedMethodName = false;
1284 MatchState matchState = new MatchState(); 1291 MatchState matchState = new MatchState();
1285 for (String k in _behaviors.keys) { 1292 for (String k in _behaviors.keys) {
1286 Behavior b = _behaviors[k]; 1293 Behavior b = _behaviors[k];
1287 if (b.matcher.nameFilter.matches(method, matchState)) { 1294 if (b.matcher.nameFilter.matches(method, matchState)) {
1288 matchedMethodName = true; 1295 matchedMethodName = true;
1289 } 1296 }
1290 if (b.matches(method, args)) { 1297 if (b.matches(method, args)) {
1291 List actions = b.actions; 1298 List actions = b.actions;
1292 if (actions == null || actions.length == 0) { 1299 if (actions == null || actions.length == 0) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 } 1459 }
1453 } 1460 }
1454 } 1461 }
1455 1462
1456 /** Clear both logs and behavior. */ 1463 /** Clear both logs and behavior. */
1457 void reset() { 1464 void reset() {
1458 resetBehavior(); 1465 resetBehavior();
1459 clearLogs(); 1466 clearLogs();
1460 } 1467 }
1461 } 1468 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | runtime/lib/invocation_mirror_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698