* Removed all Id tags.
[cacao.git] / tests / regression / jctest.java
index f2fed11deb328d57ab10f53200b23cc923ccf32c..fecc9f4ec291f2781e9057cc215e5c68c267a204 100644 (file)
@@ -1,8 +1,8 @@
 /* tests/jctest.java - checks most of the JVM instructions
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    TU Wien
 
    This file is part of CACAO.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Reinhard Grafl
-
-   Changes: Christian Thalinger
-
-   $Id: jctest.java 3131 2005-08-18 07:44:12Z twisti $
+            Christian Thalinger
 
 */
 
@@ -123,6 +120,7 @@ public class jctest implements jcinterface {
         testlong(0x3333,143444);
         testlong(4444441,12342);
         testlong(0x8000000000000000L,-1);
+        testlong(0x0000000080000000L,0x0000000080000000L);
 
         p("------------------- test floats");
         testfloat((float) 1,(float) 2.042);
@@ -245,8 +243,10 @@ public class jctest implements jcinterface {
     // ****************** test type casts and array stores *********************
 
     public static void testcasts() {
+        Object     on  = null;
         Object     o   = new Object();
         Object     oi  = new Integer(0);
+        Object[]   ona = null;
         Object[]   oa  = new Object [1];
         Object[]   oia = new Integer[1];
         Integer    i   = new Integer(0);
@@ -257,10 +257,21 @@ public class jctest implements jcinterface {
 
         p ("------------------- test casts");
 
+        p("null is instanceof Object:  ", on instanceof Object);
         p("Integer is instanceof Object:  ", oi instanceof Object);
         p("Integer is instanceof Integer: ", oi instanceof Integer);
         p("Object is instanceof Integer:  ", o instanceof Integer);
 
+        p("null is instanceof Object[]:  ", on instanceof Object[]);
+        p("Integer[] is instanceof Object[]:  ", oia instanceof Object[]);
+        p("Integer[] is instanceof Integer[]: ", oia instanceof Integer[]);
+        p("Object[] is instanceof Integer[]:  ", oa instanceof Integer[]);
+
+        p("Integer is instanceof Object[]:  ", oi instanceof Object[]);
+        p("Integer[] is instanceof Object:  ", oia instanceof Object);
+        p("Integer is instanceof Integer[]: ", oi instanceof Integer[]);
+        p("Object is instanceof Integer[]:  ", o instanceof Integer[]);
+
         try {
             p ("type cast check: Integer = Object(Integer)");
             i = (Integer) oi;
@@ -756,7 +767,7 @@ public class jctest implements jcinterface {
             }
             p("successfully created");
         } catch (Exception e) {
-            p("error: exception thrown");
+            p("error: exception thrown: " + e);
         }
 
         iaaa = new int[2][3][4];
@@ -1174,6 +1185,7 @@ public class jctest implements jcinterface {
     }
 
     static public void testdivremconst(int a) {
+        p("IDIVPOW2 (" + a + " / 0x00000001):  ", a / 0x00000001);
         p("IDIVPOW2 (" + a + " / 0x00000002):  ", a / 0x00000002);
         p("IDIVPOW2 (" + a + " / 0x00000004):  ", a / 0x00000004);
         p("IDIVPOW2 (" + a + " / 0x00000008):  ", a / 0x00000008);
@@ -1206,6 +1218,7 @@ public class jctest implements jcinterface {
         p("IDIVPOW2 (" + a + " / 0x40000000):  ", a / 0x40000000);
         p("IDIVPOW2 (" + a + " / 0x80000000):  ", a / 0x80000000);
 
+        p("IREMPOW2 (" + a + " % 0x00000001):  ", a % 0x00000001);
         p("IREMPOW2 (" + a + " % 0x00000002):  ", a % 0x00000002);
         p("IREMPOW2 (" + a + " % 0x00000004):  ", a % 0x00000004);
         p("IREMPOW2 (" + a + " % 0x00000008):  ", a % 0x00000008);
@@ -1240,6 +1253,7 @@ public class jctest implements jcinterface {
     }
 
     static public void testdivremconst(long a) {
+        p("LDIVPOW2 (" + a + " / 0x00000001):  ", a / 0x00000001);
         p("LDIVPOW2 (" + a + " / 0x00000002):  ", a / 0x00000002);
         p("LDIVPOW2 (" + a + " / 0x00000004):  ", a / 0x00000004);
         p("LDIVPOW2 (" + a + " / 0x00000008):  ", a / 0x00000008);
@@ -1272,6 +1286,7 @@ public class jctest implements jcinterface {
         p("LDIVPOW2 (" + a + " / 0x40000000):  ", a / 0x40000000);
         p("LDIVPOW2 (" + a + " / 0x80000000):  ", a / 0x80000000);
 
+        p("LREMPOW2 (" + a + " % 0x00000001):  ", a % 0x00000001L);
         p("LREMPOW2 (" + a + " % 0x00000002):  ", a % 0x00000002L);
         p("LREMPOW2 (" + a + " % 0x00000004):  ", a % 0x00000004L);
         p("LREMPOW2 (" + a + " % 0x00000008):  ", a % 0x00000008L);
@@ -1476,29 +1491,76 @@ public class jctest implements jcinterface {
     }
 
     public static void p(String a) { System.out.print(a); pnl(); }
-    public static void p(boolean a) {System.out.print(a); 
-    pnl();  }
-    public static void p(int a) { System.out.print ("int: ");
-    System.out.print(a); 
-    pnl();  }
-    public static void p(long a) { System.out.print ("long: ");
-    System.out.print(a); 
-    pnl(); }
-    public static void p(short a) { System.out.print ("short: ");
-    System.out.print(a); 
-    pnl(); }
-    public static void p(byte a) { System.out.print ("byte: ");
-    System.out.print(a); 
-    pnl(); }
-    public static void p(char a) { System.out.print ("char: ");
-    System.out.print((int) a); 
-    pnl(); }
-    public static void p(float a) { System.out.print ("float: ");
-    System.out.print ( java.lang.Float.floatToIntBits(a) ); 
-    pnl(); }
-    public static void p(double a) { System.out.print ("double: ");
-    System.out.print( java.lang.Double.doubleToLongBits(a) ); 
-    pnl(); }
+
+    public static void p(boolean a) {
+        System.out.print(a);
+        pnl();
+    }
+
+    public static void p(byte a) {
+        System.out.print("byte: ");
+        System.out.print(a);
+        System.out.print(" (0x");
+        System.out.print(Integer.toHexString(a));
+        System.out.print(")");
+        pnl();
+    }
+
+    public static void p(char a) {
+        System.out.print("char: ");
+        System.out.print((int) a);
+        System.out.print(" (0x");
+        System.out.print(Integer.toHexString((int) a));
+        System.out.print(")");
+        pnl();
+    }
+
+    public static void p(short a) {
+        System.out.print("short: ");
+        System.out.print(a);
+        System.out.print(" (0x");
+        System.out.print(Integer.toHexString(a));
+        System.out.print(")");
+        pnl();
+    }
+
+    public static void p(int a) {
+        System.out.print ("int: ");
+        System.out.print(a);
+        System.out.print(" (0x");
+        System.out.print(Integer.toHexString(a));
+        System.out.print(")");
+        pnl();
+    }
+
+    public static void p(long a) {
+        System.out.print ("long: ");
+        System.out.print(a);
+        System.out.print(" (0x");
+        System.out.print(Long.toHexString(a));
+        System.out.print(")");
+        pnl();
+    }
+
+    public static void p(float a) {
+        int i = Float.floatToIntBits(a);
+        System.out.print("float: ");
+        System.out.print(i);
+        System.out.print(" (0x");
+        System.out.print(Integer.toHexString(i));
+        System.out.print(")");
+        pnl();
+    }
+
+    public static void p(double a) {
+        long l = Double.doubleToLongBits(a);
+        System.out.print("double: ");
+        System.out.print(l);
+        System.out.print(" (0x");
+        System.out.print(Long.toHexString(l));
+        System.out.print(")");
+        pnl();
+    }
 
     public static void p(String s,boolean i) { 
         System.out.print(s); p(i);