RelationalSymbolicValue extends BinarySymbolicValue { @VisibleForTesting RelationalSymbolicValue deduceTransitiveOrSimplified(RelationalSymbolicValue other) { RelationalSymbolicValue result = simplify(other); if (result != null) { return result; } return combineTransitively(other); } RelationalSymbolicValue(Kind kind); @VisibleForTesting  RelationalSymbolicValue(Kind kind, SymbolicValue leftOp, SymbolicValue rightOp); @Override List<ProgramState> setConstraint(ProgramState initialProgramState, BooleanConstraint booleanConstraint); @Override boolean equals(Object o); boolean isEquality(); @Override int hashCode(); @Override String toString(); @VisibleForTesting Kind kind();  }
@Test void test_transitive_GE() throws Exception { RelationalSymbolicValue ab = relationalSV(Tree.Kind.GREATER_THAN_OR_EQUAL_TO, a, b); RelationalSymbolicValue bc = relationalSV(Tree.Kind.GREATER_THAN_OR_EQUAL_TO, b, c); RelationalSymbolicValue deduced = ab.deduceTransitiveOrSimplified(bc); assertThat(deduced).isEqualTo(relationalSV(Tree.Kind.GREATER_THAN_OR_EQUAL_TO, a, c)); }
@Test void test_transitive_method_equals() throws Exception { RelationalSymbolicValue equalAB = relationalSV(Tree.Kind.EQUAL_TO, a, b); RelationalSymbolicValue methodEqualBC = new RelationalSymbolicValue(METHOD_EQUALS, b, c); RelationalSymbolicValue deduced = equalAB.deduceTransitiveOrSimplified(methodEqualBC); RelationalSymbolicValue expected = new RelationalSymbolicValue(METHOD_EQUALS, a, c); assertThat(deduced).isEqualTo(expected); deduced = methodEqualBC.deduceTransitiveOrSimplified(equalAB); assertThat(deduced).isEqualTo(expected); }
@Test void test_not_equals_is_not_transitive() throws Exception { RelationalSymbolicValue aNEb = relationalSV(Tree.Kind.NOT_EQUAL_TO, a, b); RelationalSymbolicValue bNEc = relationalSV(Tree.Kind.NOT_EQUAL_TO, b, c); RelationalSymbolicValue relation = aNEb.deduceTransitiveOrSimplified(bNEc); assertThat(relation).isNull(); }