Esempio n. 1
0
  @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);
  }
Esempio n. 2
0
  @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);
  }
Esempio n. 3
0
 @Test
 public void testSimpleReturn() {
   mainBlock.addReturnValue(6);
   int result = runMain();
   assertEquals(6, result);
 }