easyforgood / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

areEqual does not try == operator for trivial equality case and sometimes has unneccessary exceptions #484

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Any class that throws an exception in its equals method.  For example:

private final class BadEquals {
   @Override
        public boolean equals (Object oth) {
          throw new RuntimeException();
        }
   }
2. Create an instance of that class.  Object badequals=new BadEquals();
3. Test for equality using org.mockito.internal.matchers.Equality.areEqual:  
areEqual(badequals,badequals)

What is the expected output? What do you see instead?
I expect to see they are equal.

I suspect that the areEqual method is calling the equals method which is 
throwing an Exception.  In this case, we can use the java equality operator to 
see that they are equal, bypassing the equals method and its exception.

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by Emory.Me...@gmail.com on 6 Apr 2014 at 9:21

GoogleCodeExporter commented 8 years ago
Pushed to master. Thanks a lot for the pull request!

Original comment by szcze...@gmail.com on 20 Apr 2014 at 1:55

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 16 Aug 2014 at 2:43

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 24 Aug 2014 at 3:14

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 24 Aug 2014 at 3:50