Mercurial > hg > truffle
changeset 22493:1cb72700c10e
Increase test coverage for ExactClassValueProfile class.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 12 Dec 2015 13:34:49 +0100 |
parents | bc3303fb3888 |
children | cff4a9d3e72a |
files | truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/utilities/ExactClassValueProfileTest.java |
diffstat | 1 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/utilities/ExactClassValueProfileTest.java Thu Dec 10 18:39:47 2015 +0100 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/utilities/ExactClassValueProfileTest.java Sat Dec 12 13:34:49 2015 +0100 @@ -24,6 +24,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; @@ -44,9 +45,17 @@ @DataPoint public static final Object O3 = new Object(); @DataPoint public static final Integer O4 = new Integer(1); @DataPoint public static final Integer O5 = null; + @DataPoint public static final TestBaseClass O6 = new TestBaseClass(); + @DataPoint public static final TestSubClass O7 = new TestSubClass(); private ValueProfile profile; + private static class TestBaseClass { + } + + private static class TestSubClass extends TestBaseClass { + } + @Before public void create() { profile = ValueProfile.createClassProfile(); @@ -57,7 +66,7 @@ assertThat(isGeneric(profile), is(false)); assertThat(isUninitialized(profile), is(true)); assertNull(getCachedClass(profile)); - profile.toString(); // test that it is not crashing + assertNotNull(profile.toString()); } @Theory @@ -65,9 +74,9 @@ Object result = profile.profile(value); assertThat(result, is(value)); - assertEquals(getCachedClass(profile), expectedClass(value)); + assertEquals(expectedClass(value), getCachedClass(profile)); assertThat(isUninitialized(profile), is(false)); - profile.toString(); // test that it is not crashing + assertNotNull(profile.toString()); } @Theory @@ -80,10 +89,10 @@ Object expectedClass = expectedClass(value0) == expectedClass(value1) ? expectedClass(value0) : Object.class; - assertEquals(getCachedClass(profile), expectedClass); + assertEquals(expectedClass, getCachedClass(profile)); assertThat(isUninitialized(profile), is(false)); assertThat(isGeneric(profile), is(expectedClass == Object.class)); - profile.toString(); // test that it is not crashing + assertNotNull(profile.toString()); } @Theory @@ -98,10 +107,10 @@ Object expectedClass = expectedClass(value0) == expectedClass(value1) && expectedClass(value1) == expectedClass(value2) ? expectedClass(value0) : Object.class; - assertEquals(getCachedClass(profile), expectedClass); + assertEquals(expectedClass, getCachedClass(profile)); assertThat(isUninitialized(profile), is(false)); assertThat(isGeneric(profile), is(expectedClass == Object.class)); - profile.toString(); // test that it is not crashing + assertNotNull(profile.toString()); } private static Class<?> expectedClass(Object value) {