Package haikuvm.bench.from.darjeeling.testvm.classes

Examples of haikuvm.bench.from.darjeeling.testvm.classes.A


      Darjeeling.assertTrue(testBase+40, true);
    }
   
    // nullpointer test
    try {
      A a = null;
      a.x = 10;
      Darjeeling.assertTrue(testBase+50, false);
    } catch (NullPointerException ex)
    {
      Darjeeling.assertTrue(testBase+50, true);
    }

        try {
      A a = null;
      int x = a.x;
      Darjeeling.assertTrue(testBase+51, false);
    } catch (NullPointerException ex)
    {
      Darjeeling.assertTrue(testBase+51, true);
    }

       
    // out of bounds tests

        // test with negative index
        try {
      byte[] arr = new byte[0];
      arr[-1] = 10;
      Darjeeling.assertTrue(testBase+60, false);
    } catch (IndexOutOfBoundsException ex)
    {
      Darjeeling.assertTrue(testBase+60, true);
    }

        // test with index 0 on empty array
    try {
      short[] arr = new short[0];
      arr[0] = 10;
      Darjeeling.assertTrue(testBase+61, false);
    } catch (IndexOutOfBoundsException ex)
    {
      Darjeeling.assertTrue(testBase+61, true);
    }

        // test with index 0 on one-slot array
        try {
      int[] arr = new int[1];
      arr[0] = 10;
      Darjeeling.assertTrue(testBase+62, true);
    } catch (IndexOutOfBoundsException ex)
    {
      Darjeeling.assertTrue(testBase+62, false);
    }

        // test with index beyond array size
    try {
      int[] arr = new int[10];
      arr[10] = 10;
      Darjeeling.assertTrue(testBase+63, false);
    } catch (IndexOutOfBoundsException ex)
    {
      Darjeeling.assertTrue(testBase+63, true);
    }

    // hacky test
    /*
    try {
      SinkList sinks = new SinkList();
      sinks.add(new Sink((short)1));
      int size = sinks.size();
      Darjeeling.assertTrue(testBase+70, true);
    } catch (Error err)
    {
      Darjeeling.assertTrue(testBase+70, false);
    }
    */
   
    // hacky test
    try {
      A a = new A();
      a.x = 10;
      Darjeeling.assertTrue(testBase+80, a.createInner().getX()==10);
    } catch (Error err)
    {
      Darjeeling.assertTrue(testBase+80, false);
    }
   
View Full Code Here


 
  public static void test(int testBase)
  {
    // class cast exception test
    try {
      A a = new A();
      B b = (B)a;
      Darjeeling.assertTrue(testBase + 0, false);
    } catch (ClassCastException ex)
    {
      Darjeeling.assertTrue(testBase + 0, true);
View Full Code Here

        test(0);
        System.out.println("Done");
    }
  public static void constructorTest(int testBase)
  {
    A a = new A();
    Darjeeling.assertTrue(testBase +  0, a.getX()==2);
    Darjeeling.assertTrue(testBase +  1, a.getY()==3);
    Darjeeling.assertTrue(testBase +  2, a.getSquaredLength()==2*2+3*3);

    a = new A(5,-2);
    Darjeeling.assertTrue(testBase +  3, a.getX()==5);
    Darjeeling.assertTrue(testBase +  4, a.getY()==-2);
    Darjeeling.assertTrue(testBase +  5, a.getSquaredLength()==5*5+-2*-2);
  }
 
View Full Code Here

    Darjeeling.assertTrue(testBase +  5, a.getSquaredLength()==5*5+-2*-2);
  }

  public static void inheritanceTest(int testBase)
  {
    A a, b, c, d;
    E e;
   
    a = new A();
    b = new B();
    c = new C();
    d = new D();
    e = new E();
   
    Darjeeling.assertTrue(testBase +  0, a.virtualMethod()==0);
    Darjeeling.assertTrue(testBase +  1, b.virtualMethod()==1);
    Darjeeling.assertTrue(testBase +  2, c.virtualMethod()==2);
    Darjeeling.assertTrue(testBase +  3, d.virtualMethod()==3);

    Darjeeling.assertTrue(testBase +  4, a.AInterfaceMethod()==0);
    Darjeeling.assertTrue(testBase +  5, b.AInterfaceMethod()==0);
    Darjeeling.assertTrue(testBase +  6, c.AInterfaceMethod()==0);
    Darjeeling.assertTrue(testBase +  7, d.AInterfaceMethod()==0);
    Darjeeling.assertTrue(testBase +  8, e.AInterfaceMethod()==1);
   
View Full Code Here

 
  private static A staticA;
 
  public static void simpleObjectTest(short testBase)
  {
    staticA = new A(-3,2);
    A localA = new A(12,8);
   
    for (short i=0; i<1000; i++)
    {
      A a = new A(i,i*2);
    }

    System.gc();
       
    Darjeeling.assertTrue(testBase +  0, true);
View Full Code Here

   
  private static void instanceOfTest(int testBase)
  {
   
    // test NEW and INSTANCEOF
    A a = new A();// A implements AInterface
    B b = new B();// B extends A
    C c = new C();// C extends B implents CInterface
    D d = new D();// D extends C
    String str = new String();
    Inner inner = new Inner();
View Full Code Here

   
  }
 
  public static void interfaceImplementTest(int testBase)
  {
    A a = new A();
    B b = new B();
    C c = new C();
    D d = new D();
    E e = new E();
        Inner inner = new Inner();
View Full Code Here

  }

  private static void checkcastTest(int testBase)
  {
    // check cast
    Object a = new A();
    Object b = new B();
    Object c = new C();
    Object d = new D();

    Object o = b;
View Full Code Here

TOP

Related Classes of haikuvm.bench.from.darjeeling.testvm.classes.A

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.