@Test public void testIfFalse() { // if it == 0 return 1 args.set("it", 2); Expr expr = new MathExpr(MathExpr.Operation.EQ, ValueExpr.createVar("it"), ValueExpr.createValue(0)); Block block = new Block(); block.addReturnValue(1); mainBlock.addStatement(new IfStatement(expr, block)); mainBlock.addReturnValue(0); int result = runMain(); assertEquals(0, result); }
@Test public void testSimpleCall() { Block other = new Block(); other.addReturnValue(5); addFunc("other", other); mainBlock.addStatement(new ReturnStatement(new FuncExpr("other", new ArrayList<IntOrVar>()))); int result = runMain(); assertEquals(5, result); }
@Test public void testSimpleReturn() { mainBlock.addReturnValue(6); int result = runMain(); assertEquals(6, result); }