OLD | NEW |
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 /** | 5 /** |
6 * The error formatter for mocking is a bit different from the default one | 6 * The error formatter for mocking is a bit different from the default one |
7 * for unit testing; instead of the third argument being a 'reason' | 7 * for unit testing; instead of the third argument being a 'reason' |
8 * it is instead a [signature] describing the method signature filter | 8 * it is instead a [signature] describing the method signature filter |
9 * that was used to select the logs that were verified. | 9 * that was used to select the logs that were verified. |
10 */ | 10 */ |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 logs = new List<LogEntry>(); | 363 logs = new List<LogEntry>(); |
364 } | 364 } |
365 | 365 |
366 /** Add a [LogEntry] to the log. */ | 366 /** Add a [LogEntry] to the log. */ |
367 add(LogEntry entry) => logs.add(entry); | 367 add(LogEntry entry) => logs.add(entry); |
368 | 368 |
369 /** Get the first entry, or null if no entries. */ | 369 /** Get the first entry, or null if no entries. */ |
370 get first => (logs == null || logs.length == 0) ? null : logs[0]; | 370 get first => (logs == null || logs.length == 0) ? null : logs[0]; |
371 | 371 |
372 /** Get the last entry, or null if no entries. */ | 372 /** Get the last entry, or null if no entries. */ |
373 get last => (logs == null || logs.length == 0) ? null : logs.last(); | 373 get last => (logs == null || logs.length == 0) ? null : logs.last; |
374 | 374 |
375 /** Creates a LogEntry predicate function from the argument. */ | 375 /** Creates a LogEntry predicate function from the argument. */ |
376 Function _makePredicate(arg) { | 376 Function _makePredicate(arg) { |
377 if (arg == null) { | 377 if (arg == null) { |
378 return (e) => true; | 378 return (e) => true; |
379 } else if (arg is CallMatcher) { | 379 } else if (arg is CallMatcher) { |
380 return (e) => arg.matches(e.methodName, e.args); | 380 return (e) => arg.matches(e.methodName, e.args); |
381 } else if (arg is Function) { | 381 } else if (arg is Function) { |
382 return arg; | 382 return arg; |
383 } else { | 383 } else { |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 } | 1450 } |
1451 } | 1451 } |
1452 } | 1452 } |
1453 | 1453 |
1454 /** Clear both logs and behavior. */ | 1454 /** Clear both logs and behavior. */ |
1455 void reset() { | 1455 void reset() { |
1456 resetBehavior(); | 1456 resetBehavior(); |
1457 clearLogs(); | 1457 clearLogs(); |
1458 } | 1458 } |
1459 } | 1459 } |
OLD | NEW |