Class BinaryOperationTest
java.lang.Object
org.checkerframework.dataflow.expression.BinaryOperationTest
Tests that
BinaryOperation.equals(Object) and BinaryOperation.hashCode() stay
consistent with each other (see the contract of Object.hashCode()), in particular for
commutative operators, where equals considers a OP b and b OP a equal.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks thatequalsconsiders1 + 2and2 + 1equal.voidChecks thathashCodeagrees withequals: since1 + 2and2 + 1are equal, they must hash identically.voidChecks thatequalsdistinguishes1 - 2from2 - 1.voidChecks thathashCoderemains order-sensitive for a non-commutative operator, i.e.voidsetUp()Builds a minimalProcessingEnvironment(following the same approach asAnnotationBuilderTest) so that a realTypeMirroris available for the operands and result type of theBinaryOperations under test.
-
Constructor Details
-
BinaryOperationTest
public BinaryOperationTest()
-
-
Method Details
-
setUp
public void setUp()Builds a minimalProcessingEnvironment(following the same approach asAnnotationBuilderTest) so that a realTypeMirroris available for the operands and result type of theBinaryOperations under test. -
commutativeEqualsIsOrderIndependent
public void commutativeEqualsIsOrderIndependent()Checks thatequalsconsiders1 + 2and2 + 1equal. -
commutativeHashCodeIsOrderIndependent
public void commutativeHashCodeIsOrderIndependent()Checks thathashCodeagrees withequals: since1 + 2and2 + 1are equal, they must hash identically. This is the contract violation reported in issue #1653. -
nonCommutativeEqualsIsOrderSensitive
public void nonCommutativeEqualsIsOrderSensitive()Checks thatequalsdistinguishes1 - 2from2 - 1. -
nonCommutativeHashCodeIsOrderSensitive
public void nonCommutativeHashCodeIsOrderSensitive()Checks thathashCoderemains order-sensitive for a non-commutative operator, i.e. that the fix for commutative operators did not makehashCodeorder-independent in general.
-