Mercurial > hg > graal-jvmci-8
changeset 5617:19ca9e48cd31
added more tests to NewInstanceTest
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 15 Jun 2012 12:05:13 +0200 |
parents | 310ed6650682 |
children | 60ca7d300b8f |
files | graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/NewInstanceTest.java |
diffstat | 1 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/NewInstanceTest.java Fri Jun 15 12:04:26 2012 +0200 +++ b/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/NewInstanceTest.java Fri Jun 15 12:05:13 2012 +0200 @@ -36,12 +36,20 @@ Assert.assertTrue(expected != null); Assert.assertTrue(actual != null); super.assertEquals(expected.getClass(), actual.getClass()); + if (expected.getClass() != Object.class) { + try { + expected.getClass().getDeclaredMethod("equals", Object.class); + super.assertEquals(expected, actual); + } catch (Exception e) { + } + } } @Test public void test1() { test("newObject"); test("newBigObject"); + test("newSomeObject"); test("newEmptyString"); test("newString", "value"); test("newHashMap", 31); @@ -55,6 +63,10 @@ return new BigObject(); } + public static SomeObject newSomeObject() { + return new SomeObject(); + } + public static String newEmptyString() { return new String(); } @@ -67,6 +79,30 @@ return new HashMap(initialCapacity); } + static class SomeObject { + String name = "o1"; + HashMap<String, Object> map = new HashMap<>(); + + + public SomeObject() { + map.put(name, this.getClass()); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof SomeObject) { + SomeObject so = (SomeObject) obj; + return so.name.equals(name) && so.map.equals(map); + } + return false; + } + + @Override + public int hashCode() { + return name.hashCode(); + } + } + static class BigObject { Object f01; Object f02;