@Test public void same_single_value_constraint_comparison() throws Exception { state = state.constrain(sv1, Constraint.EMPTY_STRING_PRIMITIVE).get() .constrain(sv2, Constraint.EMPTY_STRING_PRIMITIVE).get(); assertThat(equalTo.baseConstraint(state)).isEqualTo(Constraint.TRUE); assertThat(strictEqualTo.baseConstraint(state)).isEqualTo(Constraint.TRUE); assertThat(notEqualTo.baseConstraint(state)).isEqualTo(Constraint.FALSE); assertThat(strictNotEqualTo.baseConstraint(state)).isEqualTo(Constraint.FALSE); }
@Override public Constraint baseConstraint(ProgramState state) { final Constraint leftConstraint = state.getConstraint(leftOperand); final Constraint rightConstraint = state.getConstraint(rightOperand); if (leftConstraint.isIncompatibleWith(rightConstraint)) { if (kind == Kind.STRICT_EQUAL_TO) { return Constraint.FALSE; } if (kind == Kind.STRICT_NOT_EQUAL_TO) { return Constraint.TRUE; } } Constraint singleValueEqualityConstraint = resolveSingleValueEqualityConstraint(leftConstraint, rightConstraint); if (singleValueEqualityConstraint != null) { return singleValueEqualityConstraint; } return super.baseConstraint(state); }
EqualitySymbolicValue extends RelationalSymbolicValue { @Override public Constraint baseConstraint(ProgramState state) { final Constraint leftConstraint = state.getConstraint(leftOperand); final Constraint rightConstraint = state.getConstraint(rightOperand); if (leftConstraint.isIncompatibleWith(rightConstraint)) { if (kind == Kind.STRICT_EQUAL_TO) { return Constraint.FALSE; } if (kind == Kind.STRICT_NOT_EQUAL_TO) { return Constraint.TRUE; } } Constraint singleValueEqualityConstraint = resolveSingleValueEqualityConstraint(leftConstraint, rightConstraint); if (singleValueEqualityConstraint != null) { return singleValueEqualityConstraint; } return super.baseConstraint(state); } }
EqualitySymbolicValue extends RelationalSymbolicValue { @Override public Constraint baseConstraint(ProgramState state) { final Constraint leftConstraint = state.getConstraint(leftOperand); final Constraint rightConstraint = state.getConstraint(rightOperand); if (leftConstraint.isIncompatibleWith(rightConstraint)) { if (kind == Kind.STRICT_EQUAL_TO) { return Constraint.FALSE; } if (kind == Kind.STRICT_NOT_EQUAL_TO) { return Constraint.TRUE; } } Constraint singleValueEqualityConstraint = resolveSingleValueEqualityConstraint(leftConstraint, rightConstraint); if (singleValueEqualityConstraint != null) { return singleValueEqualityConstraint; } return super.baseConstraint(state); } EqualitySymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); }
EqualitySymbolicValue extends RelationalSymbolicValue { @Override public Constraint baseConstraint(ProgramState state) { final Constraint leftConstraint = state.getConstraint(leftOperand); final Constraint rightConstraint = state.getConstraint(rightOperand); if (leftConstraint.isIncompatibleWith(rightConstraint)) { if (kind == Kind.STRICT_EQUAL_TO) { return Constraint.FALSE; } if (kind == Kind.STRICT_NOT_EQUAL_TO) { return Constraint.TRUE; } } Constraint singleValueEqualityConstraint = resolveSingleValueEqualityConstraint(leftConstraint, rightConstraint); if (singleValueEqualityConstraint != null) { return singleValueEqualityConstraint; } return super.baseConstraint(state); } EqualitySymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); @Override Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint); @Override Constraint baseConstraint(ProgramState state); }
EqualitySymbolicValue extends RelationalSymbolicValue { @Override public Constraint baseConstraint(ProgramState state) { final Constraint leftConstraint = state.getConstraint(leftOperand); final Constraint rightConstraint = state.getConstraint(rightOperand); if (leftConstraint.isIncompatibleWith(rightConstraint)) { if (kind == Kind.STRICT_EQUAL_TO) { return Constraint.FALSE; } if (kind == Kind.STRICT_NOT_EQUAL_TO) { return Constraint.TRUE; } } Constraint singleValueEqualityConstraint = resolveSingleValueEqualityConstraint(leftConstraint, rightConstraint); if (singleValueEqualityConstraint != null) { return singleValueEqualityConstraint; } return super.baseConstraint(state); } EqualitySymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); @Override Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint); @Override Constraint baseConstraint(ProgramState state);  }