changeset 6305:94ed0ba0a1f2

added more tests to InstanceOfTest for testing against types with a deep hierarchy
author Doug Simon <doug.simon@oracle.com>
date Fri, 31 Aug 2012 22:56:29 +0200
parents ed73a5639244
children 1bb742086acd
files graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java
diffstat 1 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java	Fri Aug 31 22:55:34 2012 +0200
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java	Fri Aug 31 22:56:29 2012 +0200
@@ -30,6 +30,7 @@
 import com.oracle.graal.compiler.phases.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.snippets.CheckCastTest.*;
 
 /**
  * Tests the implementation of instanceof, allowing profiling information to
@@ -135,6 +136,32 @@
         test("isMapInt",    profile(TreeMap.class, HashMap.class), Object.class);
     }
 
+    @Test
+    public void test7() {
+        Object o = new Depth13();
+        test("isDepth12",   profile(), o);
+        test("isDepth12",   profile(Depth13.class), o);
+        test("isDepth12",   profile(Depth13.class, Depth14.class), o);
+
+        o = "not a depth";
+        test("isDepth12",   profile(), o);
+        test("isDepth12",   profile(Depth13.class), o);
+        test("isDepth12",   profile(Depth13.class, Depth14.class), o);
+    }
+
+    @Test
+    public void test8() {
+        Object o = new Depth13();
+        test("isDepth12Int",   profile(), o);
+        test("isDepth12Int",   profile(Depth13.class), o);
+        test("isDepth12Int",   profile(Depth13.class, Depth14.class), o);
+
+        o = "not a depth";
+        test("isDepth12Int",   profile(), o);
+        test("isDepth12Int",   profile(Depth13.class), o);
+        test("isDepth12Int",   profile(Depth13.class, Depth14.class), o);
+    }
+
     public static boolean isString(Object o) {
         return o instanceof String;
     }
@@ -189,4 +216,15 @@
         }
         return 0;
     }
+
+    public static boolean isDepth12(Object o) {
+        return o instanceof Depth12;
+    }
+
+    public static int isDepth12Int(Object o) {
+        if (o instanceof Depth12) {
+            return id(0);
+        }
+        return id(0);
+    }
 }