| 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 * A simple mocking/spy library. | 6 * A simple mocking/spy library. |
| 7 * | 7 * |
| 8 * To create a mock objects for some class T, create a new class using: | 8 * To create a mock objects for some class T, create a new class using: |
| 9 * | 9 * |
| 10 * class MockT extends Mock implements T {}; | 10 * class MockT extends Mock implements T {}; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 arg6 = _noArg, | 191 arg6 = _noArg, |
| 192 arg7 = _noArg, | 192 arg7 = _noArg, |
| 193 arg8 = _noArg, | 193 arg8 = _noArg, |
| 194 arg9 = _noArg]) { | 194 arg9 = _noArg]) { |
| 195 if (name == null) { | 195 if (name == null) { |
| 196 nameFilter = anything; | 196 nameFilter = anything; |
| 197 } else { | 197 } else { |
| 198 nameFilter = wrapMatcher(name); | 198 nameFilter = wrapMatcher(name); |
| 199 } | 199 } |
| 200 argMatchers = new List<Matcher>(); | 200 argMatchers = new List<Matcher>(); |
| 201 if (arg0 === _noArg) return; | 201 if (identical(arg0, _noArg)) return; |
| 202 argMatchers.add(wrapMatcher(arg0)); | 202 argMatchers.add(wrapMatcher(arg0)); |
| 203 if (arg1 === _noArg) return; | 203 if (identical(arg1, _noArg)) return; |
| 204 argMatchers.add(wrapMatcher(arg1)); | 204 argMatchers.add(wrapMatcher(arg1)); |
| 205 if (arg2 === _noArg) return; | 205 if (identical(arg2, _noArg)) return; |
| 206 argMatchers.add(wrapMatcher(arg2)); | 206 argMatchers.add(wrapMatcher(arg2)); |
| 207 if (arg3 === _noArg) return; | 207 if (identical(arg3, _noArg)) return; |
| 208 argMatchers.add(wrapMatcher(arg3)); | 208 argMatchers.add(wrapMatcher(arg3)); |
| 209 if (arg4 === _noArg) return; | 209 if (identical(arg4, _noArg)) return; |
| 210 argMatchers.add(wrapMatcher(arg4)); | 210 argMatchers.add(wrapMatcher(arg4)); |
| 211 if (arg5 === _noArg) return; | 211 if (identical(arg5, _noArg)) return; |
| 212 argMatchers.add(wrapMatcher(arg5)); | 212 argMatchers.add(wrapMatcher(arg5)); |
| 213 if (arg6 === _noArg) return; | 213 if (identical(arg6, _noArg)) return; |
| 214 argMatchers.add(wrapMatcher(arg6)); | 214 argMatchers.add(wrapMatcher(arg6)); |
| 215 if (arg7 === _noArg) return; | 215 if (identical(arg7, _noArg)) return; |
| 216 argMatchers.add(wrapMatcher(arg7)); | 216 argMatchers.add(wrapMatcher(arg7)); |
| 217 if (arg8 === _noArg) return; | 217 if (identical(arg8, _noArg)) return; |
| 218 argMatchers.add(wrapMatcher(arg8)); | 218 argMatchers.add(wrapMatcher(arg8)); |
| 219 if (arg9 === _noArg) return; | 219 if (identical(arg9, _noArg)) return; |
| 220 argMatchers.add(wrapMatcher(arg9)); | 220 argMatchers.add(wrapMatcher(arg9)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 /** | 223 /** |
| 224 * We keep our behavior specifications in a Map, which is keyed | 224 * We keep our behavior specifications in a Map, which is keyed |
| 225 * by the [CallMatcher]. To make the keys unique and to get a | 225 * by the [CallMatcher]. To make the keys unique and to get a |
| 226 * descriptive value for the [CallMatcher] we have this override | 226 * descriptive value for the [CallMatcher] we have this override |
| 227 * of [toString()]. | 227 * of [toString()]. |
| 228 */ | 228 */ |
| 229 String toString() { | 229 String toString() { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 d.add(') ${action == Action.THROW ? "threw" : "returned"} '); | 412 d.add(') ${action == Action.THROW ? "threw" : "returned"} '); |
| 413 d.addDescriptionOf(value); | 413 d.addDescriptionOf(value); |
| 414 return d.toString(); | 414 return d.toString(); |
| 415 } | 415 } |
| 416 } | 416 } |
| 417 | 417 |
| 418 /** Utility function for optionally qualified method names */ | 418 /** Utility function for optionally qualified method names */ |
| 419 String _qualifiedName(owner, String method) { | 419 String _qualifiedName(owner, String method) { |
| 420 if (owner == null || owner === anything) { | 420 if (owner == null || identical(owner, anything)) { |
| 421 return method; | 421 return method; |
| 422 } else if (owner is Matcher) { | 422 } else if (owner is Matcher) { |
| 423 Description d = new StringDescription(); | 423 Description d = new StringDescription(); |
| 424 d.addDescriptionOf(owner); | 424 d.addDescriptionOf(owner); |
| 425 d.add('.'); | 425 d.add('.'); |
| 426 d.add(method); | 426 d.add(method); |
| 427 return d.toString(); | 427 return d.toString(); |
| 428 } else { | 428 } else { |
| 429 return '$owner.$method'; | 429 return '$owner.$method'; |
| 430 } | 430 } |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 } | 1464 } |
| 1465 } | 1465 } |
| 1466 } | 1466 } |
| 1467 | 1467 |
| 1468 /** Clear both logs and behavior. */ | 1468 /** Clear both logs and behavior. */ |
| 1469 void reset() { | 1469 void reset() { |
| 1470 resetBehavior(); | 1470 resetBehavior(); |
| 1471 clearLogs(); | 1471 clearLogs(); |
| 1472 } | 1472 } |
| 1473 } | 1473 } |
| OLD | NEW |