1. loomis
  2. mockito-flex

Wiki

Clone wiki

mockito-flex / Additions

Interesting matchers

A matcher that assumes equals() function to match actual value (by Marc Speck).

public class EqualsMatcher implements Matcher
{
    private var _instanceWithEqualsMethod:*

    function EqualsMatcher(instanceWithEqualsMethod:*) {
        if ("equals" in instanceWithEqualsMethod) {
            _instanceWithEqualsMethod = instanceWithEqualsMethod
        } else {
            throw new ArgumentError("Class must have an equal method, but "
+ instanceWithEqualsMethod + " does not have one.")
        }
    }

    public function matches(value:*):Boolean {
            return _instanceWithEqualsMethod.equals(value)
    }

    public function describe():String {
        return "reference.equals(actual)";
    }
} 

Updated