Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract invocation matching logic into InvocationShape #662

Merged
merged 4 commits into from
Aug 24, 2018

Commits on Aug 24, 2018

  1. Extract invocation matching into InvocationShape

    This moves all logic from `MethodCall` that is related to invocation
    matching into a dedicated new type, `InvocationShape`. This seems use-
    ful mainly because of two reasons:
    
     1. The invocation matching becomes more easily testable once it is
        better isolated.
    
     2. Verification methods such as `mock.Verify(expression)` no longer
        need to instantiate a transient `MethodCall` (which at its heart
        really represents a setup) in order to match invocations. They
        will be able to use the much lighter-weight `InvocationShape` in-
        stead.
    stakx committed Aug 24, 2018
    Configuration menu
    Copy the full SHA
    d225e2c View commit details
    Browse the repository at this point in the history
  2. Move argument -> argument matcher transform

    If we want to be able to use `InvocationShape` in verification methods
    as well (as described in the previous commit message), it's likely
    that this type will have to be able to accept arguments, instead of
    argument matchers.
    
    Therefore, extract that logic from `MethodCall` and move it into
    `InvocationShape'.
    stakx committed Aug 24, 2018
    Configuration menu
    Copy the full SHA
    70c5714 View commit details
    Browse the repository at this point in the history
  3. "Linearise" invocation matching conditions

    Rewrite the match conditions in such a way that the positive match al-
    ways happens at the methods' end; all earlier conditions lead to an
    early return and a negative match.
    
    This makes the changed methods somewhat easier to read.
    stakx committed Aug 24, 2018
    Configuration menu
    Copy the full SHA
    a4beda3 View commit details
    Browse the repository at this point in the history
  4. Decouple verification methods from MethodCall

    This realises one of the two benefits claimed in an earlier commit
    message: verification methods are modified to use `InvocationShape`
    instead of newing up transient `MethodCall` instances (which represent
    setups and are much heavier-weight).
    stakx committed Aug 24, 2018
    Configuration menu
    Copy the full SHA
    5a1f061 View commit details
    Browse the repository at this point in the history