public void testFactorial() throws Exception {
CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("Factorial", FACTORIAL);
MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
EclipseTAC tac = new EclipseTAC(m.resolveBinding());
ConditionalExpression cond = (ConditionalExpression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
Variable r = tac.variable(cond);
TACInstruction instr;
instr = tac.instruction(cond.getExpression());
Assert.assertTrue(instr != null);
Assert.assertTrue(instr instanceof BinaryOperation);
instr = tac.instruction(cond.getThenExpression());
Assert.assertTrue(instr != null);
Assert.assertTrue(instr instanceof LoadLiteralInstruction);
Assert.assertEquals(r, ((LoadLiteralInstruction) instr).getTarget());
Assert.assertEquals("1", ((LoadLiteralInstruction) instr).getLiteral());
instr = tac.instruction(cond.getElseExpression());
Assert.assertTrue(instr != null);
Assert.assertTrue(instr instanceof MethodCallInstruction);
Assert.assertEquals(r, ((MethodCallInstruction) instr).getTarget());
Assert.assertEquals(r, tac.variable(cond.getThenExpression()));
Assert.assertEquals(r, tac.variable(cond.getElseExpression()));
}