# HG changeset patch # User Doug Simon # Date 1346446589 -7200 # Node ID 94ed0ba0a1f220ef0c4e13784a67e65e50ef66cf # Parent ed73a563924449c96c22366e2ff23e7cf4a4ad65 added more tests to InstanceOfTest for testing against types with a deep hierarchy diff -r ed73a5639244 -r 94ed0ba0a1f2 graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java --- 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); + } }