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

Hack about to fix #2796 #2797

Closed
wants to merge 3 commits into from
Closed

Commits on Nov 23, 2022

  1. Hack about to fix mockito#2796

    This PR contains changes NOT intended to be committed 'as-is', but as a showcase for a potential solution to:
    
    * mockito#2796
    * mockito#1593
    
    And potentially other vararg related issues.
    
    The crux of the issue is that Mockito needs to handle the last matcher passed to a method, when that matcher aligns with a vararg parameter and has the same type as the vararg parameter.
    
    For example,
    
    ```java
    public interface Foo {
     String m1(String... args);  // Vararg param at index 0 and type String[]
    }
    
    @test
    public void shouldWork2() throws Exception  {
      // Last matcher at index 0, and with type String[]: needs special handling!
      given(foo.m1(any(String[].class))).willReturn("var arg method");
      ...
    }
    ```
    
    In such situations that code needs to match the raw argument, _not_ the current functionality, which is to use the last matcher to match the last _non raw_ argument.
    
    Unfortunately, I'm not aware of a way to get at the type of the matcher without adding a method to `VarargMatcher`
    to get this information. This is the downside of this approach.
    big-andy-coates committed Nov 23, 2022
    Configuration menu
    Copy the full SHA
    4b1d533 View commit details
    Browse the repository at this point in the history
  2. spotless

    big-andy-coates committed Nov 23, 2022
    Configuration menu
    Copy the full SHA
    8f1bd18 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7f89900 View commit details
    Browse the repository at this point in the history