| 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 library mock; | 5 library mock; |
| 6 import 'matcher.dart'; | 6 import 'matcher.dart'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * The error formatter for mocking is a bit different from the default one | 9 * The error formatter for mocking is a bit different from the default one |
| 10 * for unit testing; instead of the third argument being a 'reason' | 10 * for unit testing; instead of the third argument being a 'reason' |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 arg6 = _noArg, | 107 arg6 = _noArg, |
| 108 arg7 = _noArg, | 108 arg7 = _noArg, |
| 109 arg8 = _noArg, | 109 arg8 = _noArg, |
| 110 arg9 = _noArg]) { | 110 arg9 = _noArg]) { |
| 111 if (name == null) { | 111 if (name == null) { |
| 112 nameFilter = anything; | 112 nameFilter = anything; |
| 113 } else { | 113 } else { |
| 114 nameFilter = wrapMatcher(name); | 114 nameFilter = wrapMatcher(name); |
| 115 } | 115 } |
| 116 argMatchers = new List<Matcher>(); | 116 argMatchers = new List<Matcher>(); |
| 117 if (arg0 === _noArg) return; | 117 if (identical(arg0, _noArg)) return; |
| 118 argMatchers.add(wrapMatcher(arg0)); | 118 argMatchers.add(wrapMatcher(arg0)); |
| 119 if (arg1 === _noArg) return; | 119 if (identical(arg1, _noArg)) return; |
| 120 argMatchers.add(wrapMatcher(arg1)); | 120 argMatchers.add(wrapMatcher(arg1)); |
| 121 if (arg2 === _noArg) return; | 121 if (identical(arg2, _noArg)) return; |
| 122 argMatchers.add(wrapMatcher(arg2)); | 122 argMatchers.add(wrapMatcher(arg2)); |
| 123 if (arg3 === _noArg) return; | 123 if (identical(arg3, _noArg)) return; |
| 124 argMatchers.add(wrapMatcher(arg3)); | 124 argMatchers.add(wrapMatcher(arg3)); |
| 125 if (arg4 === _noArg) return; | 125 if (identical(arg4, _noArg)) return; |
| 126 argMatchers.add(wrapMatcher(arg4)); | 126 argMatchers.add(wrapMatcher(arg4)); |
| 127 if (arg5 === _noArg) return; | 127 if (identical(arg5, _noArg)) return; |
| 128 argMatchers.add(wrapMatcher(arg5)); | 128 argMatchers.add(wrapMatcher(arg5)); |
| 129 if (arg6 === _noArg) return; | 129 if (identical(arg6, _noArg)) return; |
| 130 argMatchers.add(wrapMatcher(arg6)); | 130 argMatchers.add(wrapMatcher(arg6)); |
| 131 if (arg7 === _noArg) return; | 131 if (identical(arg7, _noArg)) return; |
| 132 argMatchers.add(wrapMatcher(arg7)); | 132 argMatchers.add(wrapMatcher(arg7)); |
| 133 if (arg8 === _noArg) return; | 133 if (identical(arg8, _noArg)) return; |
| 134 argMatchers.add(wrapMatcher(arg8)); | 134 argMatchers.add(wrapMatcher(arg8)); |
| 135 if (arg9 === _noArg) return; | 135 if (identical(arg9, _noArg)) return; |
| 136 argMatchers.add(wrapMatcher(arg9)); | 136 argMatchers.add(wrapMatcher(arg9)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * We keep our behavior specifications in a Map, which is keyed | 140 * We keep our behavior specifications in a Map, which is keyed |
| 141 * by the [CallMatcher]. To make the keys unique and to get a | 141 * by the [CallMatcher]. To make the keys unique and to get a |
| 142 * descriptive value for the [CallMatcher] we have this override | 142 * descriptive value for the [CallMatcher] we have this override |
| 143 * of [toString()]. | 143 * of [toString()]. |
| 144 */ | 144 */ |
| 145 String toString() { | 145 String toString() { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 d.add(') ${action == Action.THROW ? "threw" : "returned"} '); | 328 d.add(') ${action == Action.THROW ? "threw" : "returned"} '); |
| 329 d.addDescriptionOf(value); | 329 d.addDescriptionOf(value); |
| 330 return d.toString(); | 330 return d.toString(); |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 /** Utility function for optionally qualified method names */ | 334 /** Utility function for optionally qualified method names */ |
| 335 String _qualifiedName(owner, String method) { | 335 String _qualifiedName(owner, String method) { |
| 336 if (owner == null || owner === anything) { | 336 if (owner == null || identical(owner, anything)) { |
| 337 return method; | 337 return method; |
| 338 } else if (owner is Matcher) { | 338 } else if (owner is Matcher) { |
| 339 Description d = new StringDescription(); | 339 Description d = new StringDescription(); |
| 340 d.addDescriptionOf(owner); | 340 d.addDescriptionOf(owner); |
| 341 d.add('.'); | 341 d.add('.'); |
| 342 d.add(method); | 342 d.add(method); |
| 343 return d.toString(); | 343 return d.toString(); |
| 344 } else { | 344 } else { |
| 345 return '$owner.$method'; | 345 return '$owner.$method'; |
| 346 } | 346 } |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 } | 1462 } |
| 1463 } | 1463 } |
| 1464 } | 1464 } |
| 1465 | 1465 |
| 1466 /** Clear both logs and behavior. */ | 1466 /** Clear both logs and behavior. */ |
| 1467 void reset() { | 1467 void reset() { |
| 1468 resetBehavior(); | 1468 resetBehavior(); |
| 1469 clearLogs(); | 1469 clearLogs(); |
| 1470 } | 1470 } |
| 1471 } | 1471 } |
| OLD | NEW |