Package org.allspice.structured.statement

Examples of org.allspice.structured.statement.ReturnStatement


    TryFinally obj = makeObject(TryFinally.class,new TryCatchStatement(
        new FIFO<Statement>(new ThrowStatement(ARG0,null)),
        new FIFO<CatchBlock>(new CatchBlock(
            new VarDecl("java.lang.Exception","ex"),
            new FIFO<Statement>(
                new ReturnStatement(new ConstExpr(Integer.valueOf(1),null),null)
            )
            )),
        new FIFO<Statement>(),null)) ;

    assertEquals(obj.meth(new Exception()),1) ;
View Full Code Here


    public int[] meth(int arg0) ;
  }
  public void test1() throws Exception {
    SimpleArrayTest obj = makeObject(SimpleArrayTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int[]","i",new ArrayOfExpr(null,new FIFO<Expr>(ARG0)),false)),
        new FIFO<Statement>(new ReturnStatement(new VarExpr("i",null),null)),
        null
      )) ;
    assertTrue(Arrays.equals(obj.meth(5),new int[]{5})) ;
    assertTrue(Arrays.equals(obj.meth(0),new int[]{0})) ;
  }
View Full Code Here

                new FIFO<Statement>(
                  new ExprStatement(new AddInPlaceExpr(I,new ConstExpr(Integer.valueOf(1),null),null),null),
                  new ExprStatement(new AddInPlaceExpr(TOTAL,new ConstExpr(Integer.valueOf(2),null),null),null)
                ),
                null),
            new ReturnStatement(TOTAL,null)
      ),null)) ;
    assertEquals(obj.meth(5),10) ;
    assertEquals(obj.meth(0),2) ;
  }
View Full Code Here

  }

  public void test1() throws Exception {
    MyInterface obj = makeObject(MyInterface.class,   
            new ExprStatement(new PostIncExpr(ARG0,null),null),
            new ReturnStatement(ARG0,null)) ;
    assertEquals(obj.meth(5),6) ;
  }
View Full Code Here

  public static interface MethTest {
    public int meth() ;
  }
  public void test0() throws Exception {
    MethTest obj = makeObject(MethTest.class,new TryCatchStatement(
            new FIFO<Statement>(new ReturnStatement(new ConstExpr(Integer.valueOf(0),null),null)),
            new FIFO<CatchBlock>(),
            new FIFO<Statement>(new ExprStatement(new ConstExpr(Integer.valueOf(5),null),null)),
            null
          ),
          new ReturnStatement(new ConstExpr(Integer.valueOf(-1),null),null)) ;
    assertEquals(obj.meth(),0) ;
  }
View Full Code Here

            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new ConstExpr(Integer.valueOf(7),null),null),null)),
            new FIFO<CatchBlock>(),
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new PlusExpr(X,new ConstExpr(Integer.valueOf(1),null),null),null),null)),
            null
          ),
        new ReturnStatement(X,null)),
        null)) ;
    assertEquals(obj.meth(),8) ;
  }
View Full Code Here

  public void test2() throws Exception {
    MethTest obj = makeObject(MethTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int","x")),
        new FIFO<Statement>(
          new TryCatchStatement(
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new ConstExpr(Integer.valueOf(7),null),null),null),new ReturnStatement(X,null)),
            new FIFO<CatchBlock>(),
            new FIFO<Statement>(new ExprStatement(new SetValueExpr(X,new PlusExpr(X,new ConstExpr(Integer.valueOf(1),null),null),null),null)),
            null
          ),
          new ReturnStatement(new ConstExpr(Integer.valueOf(-1),null),null)),
          null)) ;
    assertEquals(obj.meth(),7) ;
  }
View Full Code Here

  }

  public void test1() throws Exception {
    MyInterface obj = makeObject(MyInterface.class,   
            new ExprStatement(new PreIncExpr(ARG0,null),null),
            new ReturnStatement(ARG0,null)) ;
    assertEquals(obj.meth(5),6) ;
  }
View Full Code Here

    public int meth() ;
  }
  public void test1() throws Exception {
    SimpleArrayTest obj = makeObject(SimpleArrayTest.class,new DeclareStatement(
        new FIFO<VarDecl>(new VarDecl("int","i",new ConstExpr(Integer.valueOf(5),null))),
        new FIFO<Statement>(new ReturnStatement(new VarExpr("i",null),null)),
        null
      )) ;
    assertEquals(obj.meth(),5) ;
  }
View Full Code Here

    public void meth(boolean arg1) ;
  }
  public void test0() throws Exception {
    Statement st = new ExprStatement(new SetValueExpr(
        new FieldVarExpr("org.allspice.structuredtobc.test.StaticFieldTestClass","boolean_field",null),ARG0,null),null) ;
    BooleanSetFieldTest obj = makeObject(BooleanSetFieldTest.class,st,new ReturnStatement(null)) ;
    obj.meth(true) ;
    assertEquals(StaticFieldTestClass.boolean_field,true) ;
    obj.meth(false) ;
    assertEquals(StaticFieldTestClass.boolean_field,false) ;
  }
View Full Code Here

TOP

Related Classes of org.allspice.structured.statement.ReturnStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.