# HG changeset patch # User Thomas Wuerthinger # Date 1449923689 -3600 # Node ID 1cb72700c10e580a9270d792ff746a7846cdb7ce # Parent bc3303fb38889f4a2921bd3dc579abb6145cc5f2 Increase test coverage for ExactClassValueProfile class. diff -r bc3303fb3888 -r 1cb72700c10e truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/utilities/ExactClassValueProfileTest.java --- 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) {