@Test public void constrained_strict_equal_propagates_single_value_constraints() throws Exception { state = state.constrain(sv1, Constraint.ANY_VALUE).get() .constrain(sv2, Constraint.EMPTY_STRING_PRIMITIVE).get(); final Optional<ProgramState> stateConstrainedToTruthy = strictEqualTo.constrainDependencies(state, Constraint.TRUTHY); assertThat(stateConstrainedToTruthy.isPresent()).isTrue(); assertThat(stateConstrainedToTruthy.get().getConstraint(sv1)).isEqualTo(Constraint.EMPTY_STRING_PRIMITIVE); final Optional<ProgramState> stateConstrainedToFalsy = strictEqualTo.constrainDependencies(state, Constraint.FALSY); assertThat(stateConstrainedToFalsy.isPresent()).isTrue(); assertThat(stateConstrainedToFalsy.get().getConstraint(sv1)).isEqualTo(Constraint.EMPTY_STRING_PRIMITIVE.not()); }
@Override public Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint) { Optional<ProgramState> constrainedState = super.constrainDependencies(incomingState, constraint); constrainedState = constrainOperand(leftOperand, rightOperand, constraint, constrainedState.orElse(null)); constrainedState = constrainOperand(rightOperand, leftOperand, constraint, constrainedState.orElse(null)); return constrainedState; }
EqualitySymbolicValue extends RelationalSymbolicValue { @Override public Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint) { Optional<ProgramState> constrainedState = super.constrainDependencies(incomingState, constraint); constrainedState = constrainOperand(leftOperand, rightOperand, constraint, constrainedState.orElse(null)); constrainedState = constrainOperand(rightOperand, leftOperand, constraint, constrainedState.orElse(null)); return constrainedState; } }
EqualitySymbolicValue extends RelationalSymbolicValue { @Override public Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint) { Optional<ProgramState> constrainedState = super.constrainDependencies(incomingState, constraint); constrainedState = constrainOperand(leftOperand, rightOperand, constraint, constrainedState.orElse(null)); constrainedState = constrainOperand(rightOperand, leftOperand, constraint, constrainedState.orElse(null)); return constrainedState; } EqualitySymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); }
EqualitySymbolicValue extends RelationalSymbolicValue { @Override public Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint) { Optional<ProgramState> constrainedState = super.constrainDependencies(incomingState, constraint); constrainedState = constrainOperand(leftOperand, rightOperand, constraint, constrainedState.orElse(null)); constrainedState = constrainOperand(rightOperand, leftOperand, constraint, constrainedState.orElse(null)); return constrainedState; } 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 Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint) { Optional<ProgramState> constrainedState = super.constrainDependencies(incomingState, constraint); constrainedState = constrainOperand(leftOperand, rightOperand, constraint, constrainedState.orElse(null)); constrainedState = constrainOperand(rightOperand, leftOperand, constraint, constrainedState.orElse(null)); return constrainedState; } EqualitySymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); @Override Optional<ProgramState> constrainDependencies(ProgramState incomingState, Constraint constraint); @Override Constraint baseConstraint(ProgramState state);  }