16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.graalvm.compiler.core.test; 24 25 import static org.junit.Assert.assertEquals; 26 import static org.junit.Assert.assertFalse; 27 import static org.junit.Assert.assertTrue; 28 29 import java.util.Random; 30 31 import jdk.vm.ci.meta.JavaConstant; 32 33 import org.junit.Test; 34 35 import org.graalvm.compiler.core.common.calc.Condition; 36 37 public class ConditionTest { 38 39 @Test 40 public void testImplies() { 41 Random rand = new Random(13); 42 for (Condition c1 : Condition.values()) { 43 for (Condition c2 : Condition.values()) { 44 boolean implies = c1.implies(c2); 45 if (implies) { 46 for (int i = 0; i < 1000; i++) { 47 JavaConstant a = JavaConstant.forInt(rand.nextInt()); 48 JavaConstant b = JavaConstant.forInt(i < 100 ? a.asInt() : rand.nextInt()); 49 boolean result1 = c1.foldCondition(a, b, null, false); 50 boolean result2 = c2.foldCondition(a, b, null, false); 51 if (result1) { 52 assertTrue(result2); 53 } 54 } 55 } 56 } | 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.graalvm.compiler.core.test; 24 25 import static org.junit.Assert.assertEquals; 26 import static org.junit.Assert.assertFalse; 27 import static org.junit.Assert.assertTrue; 28 29 import java.util.Random; 30 31 import jdk.vm.ci.meta.JavaConstant; 32 33 import org.junit.Test; 34 35 import org.graalvm.compiler.core.common.calc.Condition; 36 import org.graalvm.compiler.test.AddExports; 37 38 @AddExports("jdk.internal.vm.ci/jdk.vm.ci.meta") 39 public class ConditionTest { 40 41 @Test 42 public void testImplies() { 43 Random rand = new Random(13); 44 for (Condition c1 : Condition.values()) { 45 for (Condition c2 : Condition.values()) { 46 boolean implies = c1.implies(c2); 47 if (implies) { 48 for (int i = 0; i < 1000; i++) { 49 JavaConstant a = JavaConstant.forInt(rand.nextInt()); 50 JavaConstant b = JavaConstant.forInt(i < 100 ? a.asInt() : rand.nextInt()); 51 boolean result1 = c1.foldCondition(a, b, null, false); 52 boolean result2 = c2.foldCondition(a, b, null, false); 53 if (result1) { 54 assertTrue(result2); 55 } 56 } 57 } 58 } |