comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/CountingConditionProfileTest.java @ 16910:c9437b07c26a

Truffle: changed return types of condition profile factory methods.
author Christian Humer <christian.humer@gmail.com>
date Sat, 23 Aug 2014 19:31:22 +0200
parents fa5e62620593
children
comparison
equal deleted inserted replaced
16909:62cfffca9be2 16910:c9437b07c26a
34 @RunWith(Theories.class) 34 @RunWith(Theories.class)
35 public class CountingConditionProfileTest { 35 public class CountingConditionProfileTest {
36 36
37 @DataPoints public static boolean[] data = new boolean[]{true, false}; 37 @DataPoints public static boolean[] data = new boolean[]{true, false};
38 38
39 private CountingConditionProfile profile;
40
41 @Before
42 public void create() {
43 profile = (CountingConditionProfile) ConditionProfile.createCountingProfile();
44 }
45
39 @Test 46 @Test
40 public void testInitial() { 47 public void testInitial() {
41 CountingConditionProfile profile = ConditionProfile.createCountingProfile();
42 assertThat(profile.getTrueCount(), is(0)); 48 assertThat(profile.getTrueCount(), is(0));
43 assertThat(profile.getFalseCount(), is(0)); 49 assertThat(profile.getFalseCount(), is(0));
44 } 50 }
45 51
46 @Theory 52 @Theory
47 public void testProfileOne(boolean value) { 53 public void testProfileOne(boolean value) {
48 CountingConditionProfile profile = ConditionProfile.createCountingProfile();
49 boolean result = profile.profile(value); 54 boolean result = profile.profile(value);
50 55
51 assertThat(result, is(value)); 56 assertThat(result, is(value));
52 assertThat(profile.getTrueCount(), is(value ? 1 : 0)); 57 assertThat(profile.getTrueCount(), is(value ? 1 : 0));
53 assertThat(profile.getFalseCount(), is(!value ? 1 : 0)); 58 assertThat(profile.getFalseCount(), is(!value ? 1 : 0));
54 } 59 }
55 60
56 @Theory 61 @Theory
57 public void testProfileTwo(boolean value0, boolean value1) { 62 public void testProfileTwo(boolean value0, boolean value1) {
58 CountingConditionProfile profile = ConditionProfile.createCountingProfile();
59 boolean result0 = profile.profile(value0); 63 boolean result0 = profile.profile(value0);
60 boolean result1 = profile.profile(value1); 64 boolean result1 = profile.profile(value1);
61 65
62 assertThat(result0, is(value0)); 66 assertThat(result0, is(value0));
63 assertThat(result1, is(value1)); 67 assertThat(result1, is(value1));
65 assertThat(profile.getFalseCount(), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0))); 69 assertThat(profile.getFalseCount(), is((!value0 ? 1 : 0) + (!value1 ? 1 : 0)));
66 } 70 }
67 71
68 @Theory 72 @Theory
69 public void testProfileThree(boolean value0, boolean value1, boolean value2) { 73 public void testProfileThree(boolean value0, boolean value1, boolean value2) {
70 CountingConditionProfile profile = ConditionProfile.createCountingProfile();
71 boolean result0 = profile.profile(value0); 74 boolean result0 = profile.profile(value0);
72 boolean result1 = profile.profile(value1); 75 boolean result1 = profile.profile(value1);
73 boolean result2 = profile.profile(value2); 76 boolean result2 = profile.profile(value2);
74 77
75 assertThat(result0, is(value0)); 78 assertThat(result0, is(value0));