drewbourne/mockolate — Issue #60: Complain on mismatched argument count
Author: drewbourne
Created: 2012-03-06 23:44:27+00:00
State: open

When specifying expected arguments using `.args()` Mockolate should verify the argument count where possible.

Example

```AS3
public class ArgumentCountExample
{
public function methodNoArgs():void {}
public function methodRequiredArgs(req1:Object, req2:Object):void {}
public function methodOptionalArgs(opt:Object = null):void {}
public function methodRestArgs(...rest):void {}
public function methodMixedArgs(req:Object, opt:Object = null, ..rest):void {}
}
```

```AS3
// accepted
mock(example).method('methodNoArgs').noArgs();
mock(example).method('methodRequiredArgs').args(1, 2);
mock(example).method('methodOptionalArgs').args(1);
mock(example).method('methodRestArgs').args(1, 2, 3);
mock(example).method('methodRestArgs').args(1, 2, 3);
mock(example).method('methodMixedArgs').args(1, 2);
mock(example).method('methodMixedArgs').args(1, 2, 3);

// denied
mock(example).method('methodNoArgs').args(1); // should throw TooManyArgumentsError
mock(example).method('methodRequiredArgs').args(1); // should throw TooFewArgumentsError
mock(example).method('methodOptionalArgs').args(1, 2); // should throw TooManyArgumentsError
```