Package org.allspice.bytecode

Examples of org.allspice.bytecode.ClassDef


    assertEquals(m.invoke(obj,0F),false) ;
    assertEquals(m.invoke(obj,2F),true) ;
  }
  public void test4() throws Exception {
   
    ClassDef cd = defadd("int",1) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",int.class) ;
    assertEquals(m.invoke(obj,-2),false) ;
    assertEquals(m.invoke(obj,0),false) ;
    assertEquals(m.invoke(obj,2),true) ;
View Full Code Here


    assertEquals(m.invoke(obj,0),false) ;
    assertEquals(m.invoke(obj,2),true) ;
  }
  public void test5() throws Exception {
   
    ClassDef cd = defadd("short",1) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",short.class) ;
    assertEquals(m.invoke(obj,(short)-1),false) ;
    assertEquals(m.invoke(obj,(short)0),false) ;
    assertEquals(m.invoke(obj,(short)1),true) ;
View Full Code Here

    assertEquals(m.invoke(obj,(short)0),false) ;
    assertEquals(m.invoke(obj,(short)1),true) ;
  }
  public void test6() throws Exception {
   
    ClassDef cd = defadd("byte",1) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",byte.class) ;
    assertEquals(m.invoke(obj,(byte)-2),false) ;
    assertEquals(m.invoke(obj,(byte)0),false) ;
    assertEquals(m.invoke(obj,(byte)2),true) ;
View Full Code Here

    assertEquals(m.invoke(obj,(byte)0),false) ;
    assertEquals(m.invoke(obj,(byte)2),true) ;
  }
  public void test7() throws Exception {
   
    ClassDef cd = defadd("char",1) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",char.class) ;
    assertEquals(m.invoke(obj,(char)-2),true) ;     
    assertEquals(m.invoke(obj,(char)0),false) ;
    assertEquals(m.invoke(obj,(char)2),true) ;
View Full Code Here

import org.allspice.bytecode.instructions.Return;
import org.allspice.bytecode.instructions.Subtract;

public class TestSub extends MyTestCase {
  public ClassDef defadd(String ret,String type,int i1,int i2) {
    ClassDef cd = makeClassDef() ;
    Var x = new Var(i1,new TypeName(type)) ;
    Var y = new Var(i2,new TypeName(type)) ;
    MethodDef md = new MethodDef(new TypeName(ret),"meth",x,y) ;
    md = md.addInstructions(
        new Load(x),
        new Load(y),
        new Subtract(TypeCode.getType(type)),
        new Return(TypeCode.getType(ret))
        ) ;
    return cd.addMethod(md)
  }
View Full Code Here

        ) ;
    return cd.addMethod(md)
  }
  public void test1() throws Exception {
   
    ClassDef cd = defadd("double","double",1,3) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",double.class,double.class) ;
    Object o = m.invoke(obj,2.0,7.0) ;
    assertEquals(o,-5.0) ;
  }
View Full Code Here

    Object o = m.invoke(obj,2.0,7.0) ;
    assertEquals(o,-5.0) ;
  }
  public void test2() throws Exception {
   
    ClassDef cd = defadd("long","long",1,3) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",long.class,long.class) ;
    Object o = m.invoke(obj,2L,7L) ;
    assertEquals(o,-5L) ;
  }
View Full Code Here

    Object o = m.invoke(obj,2L,7L) ;
    assertEquals(o,-5L) ;
  }
  public void test3() throws Exception {
   
    ClassDef cd = defadd("float","float",1,2) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",float.class,float.class) ;
    Object o = m.invoke(obj,2.0F,7.0F) ;
    assertEquals(o,-5.0F) ;
  }
View Full Code Here

    Object o = m.invoke(obj,2.0F,7.0F) ;
    assertEquals(o,-5.0F) ;
  }
  public void test4() throws Exception {
   
    ClassDef cd = defadd("int","int",1,2) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",int.class,int.class) ;
    Object o = m.invoke(obj,2,7) ;
    assertEquals(o,-5) ;
  }
View Full Code Here

    Object o = m.invoke(obj,2,7) ;
    assertEquals(o,-5) ;
  }
  public void test5() throws Exception {
   
    ClassDef cd = defadd("int","short",1,2) ;
    Object obj = makeObject(cd) ;
    Method m = obj.getClass().getMethod("meth",short.class,short.class) ;
    {
      Object o = m.invoke(obj,(short)2,(short)7) ;
      assertEquals(o,-5) ;
View Full Code Here

TOP

Related Classes of org.allspice.bytecode.ClassDef

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.