use of org.sonar.java.se.symbolicvalues.BinarySymbolicValue in project sonar-java by SonarSource.
the class BytecodeEGWalkerExecuteTest method assertBinarySymbolicValue.
private void assertBinarySymbolicValue(int[] opcodes, Class<? extends BinarySymbolicValue> binarySvClass) {
SymbolicValue sv1 = new SymbolicValue();
SymbolicValue sv2 = new SymbolicValue();
ProgramState initState = ProgramState.EMPTY_STATE.stackValue(sv2).stackValue(sv1);
for (int opcode : opcodes) {
ProgramState programState = execute(new Instruction(opcode), initState);
ProgramState.Pop pop = programState.unstackValue(1);
assertStack(programState, new Constraint[][] { { ObjectConstraint.NOT_NULL } });
SymbolicValue result = pop.values.get(0);
assertThat(result).isNotEqualTo(sv1);
assertThat(result).isNotEqualTo(sv2);
assertThat(result).isInstanceOf(binarySvClass);
assertThat(isDoubleOrLong(programState, result)).isEqualTo(LONG_OPCODE.contains(opcode));
BinarySymbolicValue andSv = (BinarySymbolicValue) result;
assertThat(andSv.getRightOp()).isEqualTo(sv1);
assertThat(andSv.getLeftOp()).isEqualTo(sv2);
}
}
Aggregations