@Test public void null_or_undefined_operand() throws Exception { assertThat( singleConstrainedState(create(Kind.LESS_THAN, sv1, NULL), Constraint.TRUTHY) .getConstraint(sv1)).isEqualTo(Constraint.ANY_VALUE); assertThat( singleConstrainedState(create(Kind.EQUAL_TO, sv1, NULL), Constraint.TRUTHY) .getConstraint(sv1)).isEqualTo(Constraint.NULL_OR_UNDEFINED); assertThat( singleConstrainedState(create(Kind.EQUAL_TO, sv1, NULL), Constraint.FALSY) .getConstraint(sv1)).isEqualTo(Constraint.NOT_NULLY); assertThat( singleConstrainedState(create(Kind.NOT_EQUAL_TO, sv1, NULL), Constraint.TRUTHY) .getConstraint(sv1)).isEqualTo(Constraint.NOT_NULLY); assertThat( singleConstrainedState(create(Kind.EQUAL_TO, UNDEFINED, sv2), Constraint.TRUTHY) .getConstraint(sv2)).isEqualTo(Constraint.NULL_OR_UNDEFINED); assertThat( singleConstrainedState(create(Kind.STRICT_EQUAL_TO, sv1, NULL), Constraint.TRUTHY) .getConstraint(sv1)).isEqualTo(Constraint.NULL); }
public static SymbolicValue create(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand) { if (KindSet.EQUALITY_KINDS.getSubKinds().contains(kind)) { return createEquality(kind, leftOperand, rightOperand); } return new RelationalSymbolicValue(kind, leftOperand, rightOperand); }
RelationalSymbolicValue implements SymbolicValue { public static SymbolicValue create(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand) { if (KindSet.EQUALITY_KINDS.getSubKinds().contains(kind)) { return createEquality(kind, leftOperand, rightOperand); } return new RelationalSymbolicValue(kind, leftOperand, rightOperand); } }
RelationalSymbolicValue implements SymbolicValue { public static SymbolicValue create(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand) { if (KindSet.EQUALITY_KINDS.getSubKinds().contains(kind)) { return createEquality(kind, leftOperand, rightOperand); } return new RelationalSymbolicValue(kind, leftOperand, rightOperand); } RelationalSymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); }
RelationalSymbolicValue implements SymbolicValue { public static SymbolicValue create(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand) { if (KindSet.EQUALITY_KINDS.getSubKinds().contains(kind)) { return createEquality(kind, leftOperand, rightOperand); } return new RelationalSymbolicValue(kind, leftOperand, rightOperand); } RelationalSymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); static SymbolicValue create(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); @Override Optional<ProgramState> constrainDependencies(ProgramState state, Constraint constraint); @Override Constraint baseConstraint(ProgramState state); Relation relationWhenTrue(); @Override String toString(); }
RelationalSymbolicValue implements SymbolicValue { public static SymbolicValue create(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand) { if (KindSet.EQUALITY_KINDS.getSubKinds().contains(kind)) { return createEquality(kind, leftOperand, rightOperand); } return new RelationalSymbolicValue(kind, leftOperand, rightOperand); } RelationalSymbolicValue(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); static SymbolicValue create(Kind kind, SymbolicValue leftOperand, SymbolicValue rightOperand); @Override Optional<ProgramState> constrainDependencies(ProgramState state, Constraint constraint); @Override Constraint baseConstraint(ProgramState state); Relation relationWhenTrue(); @Override String toString();  }