comparison graal/com.oracle.max.graal.tests/src/com/oracle/graal/compiler/tests/ConditionTest.java @ 5059:ed559a528128

Perform renames on files.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 08 Mar 2012 17:57:30 +0100
parents graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/ConditionTest.java@70b7b7071e68
children 4ed4295ce15f
comparison
equal deleted inserted replaced
5058:26f8371c229c 5059:ed559a528128
1 /*
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
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 com.oracle.max.graal.compiler.tests;
24
25 import static org.junit.Assert.*;
26
27 import java.util.*;
28
29 import org.junit.*;
30
31 import com.oracle.max.cri.ci.*;
32 import com.oracle.max.graal.nodes.calc.*;
33
34
35 public class ConditionTest {
36
37 @Test
38 public void testImplies() {
39 Random rand = new Random(13);
40 for (Condition c1 : Condition.values()) {
41 for (Condition c2 : Condition.values()) {
42 boolean implies = c1.implies(c2);
43 if (implies && c1 != Condition.OF && c2 != Condition.OF && c1 != Condition.NOF && c2 != Condition.NOF) {
44 for (int i = 0; i < 10000; i++) {
45 CiConstant a = CiConstant.forInt(rand.nextInt());
46 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
47 boolean result1 = c1.foldCondition(a, b, null, false);
48 boolean result2 = c2.foldCondition(a, b, null, false);
49 if (result1 && implies) {
50 assertTrue(result2);
51 }
52 }
53 }
54 }
55 }
56 }
57
58 @Test
59 public void testJoin() {
60 Random rand = new Random(13);
61 for (Condition c1 : Condition.values()) {
62 for (Condition c2 : Condition.values()) {
63 Condition join = c1.join(c2);
64 assertTrue(join == c2.join(c1));
65 if (join != null && c1 != Condition.OF && c2 != Condition.OF && c1 != Condition.NOF && c2 != Condition.NOF) {
66 for (int i = 0; i < 10000; i++) {
67 CiConstant a = CiConstant.forInt(rand.nextInt());
68 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
69 boolean result1 = c1.foldCondition(a, b, null, false);
70 boolean result2 = c2.foldCondition(a, b, null, false);
71 boolean resultJoin = join.foldCondition(a, b, null, false);
72 if (result1 && result2) {
73 assertTrue(resultJoin);
74 }
75 }
76 }
77 }
78 }
79 }
80
81 @Test
82 public void testMeet() {
83 Random rand = new Random(13);
84 for (Condition c1 : Condition.values()) {
85 for (Condition c2 : Condition.values()) {
86 Condition meet = c1.meet(c2);
87 assertTrue(meet == c2.meet(c1));
88 if (meet != null && c1 != Condition.OF && c2 != Condition.OF && c1 != Condition.NOF && c2 != Condition.NOF) {
89 for (int i = 0; i < 10000; i++) {
90 CiConstant a = CiConstant.forInt(rand.nextInt());
91 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
92 boolean result1 = c1.foldCondition(a, b, null, false);
93 boolean result2 = c2.foldCondition(a, b, null, false);
94 boolean resultMeet = meet.foldCondition(a, b, null, false);
95 if (result1 || result2) {
96 assertTrue(resultMeet);
97 }
98 }
99 }
100 }
101 }
102 }
103
104 }