}
@Test
public void binaryOperation() {
Program program = new Program();
BasicBlock block = program.createBasicBlock();
IntegerConstantInstruction constInsn = new IntegerConstantInstruction();
constInsn.setConstant(3);
constInsn.setReceiver(program.createVariable());
block.getInstructions().add(constInsn);
constInsn = new IntegerConstantInstruction();
constInsn.setConstant(2);
constInsn.setReceiver(program.createVariable());
block.getInstructions().add(constInsn);
BinaryInstruction addInsn = new BinaryInstruction(BinaryOperation.ADD, NumericOperandType.INT);
addInsn.setFirstOperand(program.variableAt(0));
addInsn.setSecondOperand(program.variableAt(1));
addInsn.setReceiver(program.createVariable());
block.getInstructions().add(addInsn);
BinaryInstruction subInsn = new BinaryInstruction(BinaryOperation.SUBTRACT, NumericOperandType.INT);
subInsn.setFirstOperand(program.variableAt(2));
subInsn.setSecondOperand(program.variableAt(0));
subInsn.setReceiver(program.createVariable());
block.getInstructions().add(subInsn);
assertThat(block.getInstructions().size(), is(4));
assertThat(block.getInstructions().get(2), instanceOf(BinaryInstruction.class));
assertThat(block.getInstructions().get(3), instanceOf(BinaryInstruction.class));
addInsn = (BinaryInstruction)block.getInstructions().get(2);
assertThat(addInsn.getOperation(), is(BinaryOperation.ADD));
assertThat(addInsn.getOperandType(), is(NumericOperandType.INT));
assertThat(addInsn.getFirstOperand().getIndex(), is(0));
assertThat(addInsn.getSecondOperand().getIndex(), is(1));
assertThat(addInsn.getReceiver().getIndex(), is(2));
subInsn = (BinaryInstruction)block.getInstructions().get(3);
assertThat(subInsn.getOperation(), is(BinaryOperation.SUBTRACT));
assertThat(subInsn.getOperandType(), is(NumericOperandType.INT));
assertThat(subInsn.getFirstOperand().getIndex(), is(2));
assertThat(subInsn.getSecondOperand().getIndex(), is(0));
assertThat(subInsn.getReceiver().getIndex(), is(3));