Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/ObjectStampJoinTest.java @ 11387:9088d13767f3
Keep a kind in the illegal stamp
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 21 Aug 2013 18:02:39 +0200 |
parents | e119ba892b45 |
children | 40c7cbe31aa9 |
rev | line source |
---|---|
11265 | 1 /* |
2 * Copyright (c) 2013, 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.graal.nodes.test; | |
24 | |
25 import org.junit.*; | |
26 | |
27 import com.oracle.graal.api.meta.*; | |
28 import com.oracle.graal.compiler.test.*; | |
29 import com.oracle.graal.nodes.type.*; | |
30 | |
11385
e119ba892b45
Rename StampTest to ObjectStampJoinTest and move IntegerStampTest to com.oracle.graal.nodes.test
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11265
diff
changeset
|
31 public class ObjectStampJoinTest extends GraalCompilerTest { |
11265 | 32 |
33 private static class A { | |
34 | |
35 } | |
36 | |
37 private static class B extends A { | |
38 | |
39 } | |
40 | |
41 private static class C extends B implements I { | |
42 | |
43 } | |
44 | |
45 private static class D extends A { | |
46 | |
47 } | |
48 | |
49 private interface I { | |
50 | |
51 } | |
52 | |
53 @Test | |
54 public void testJoin0() { | |
55 Stamp a = StampFactory.declared(getType(A.class)); | |
56 Stamp b = StampFactory.declared(getType(B.class)); | |
57 Assert.assertEquals(b, join(a, b)); | |
58 } | |
59 | |
60 @Test | |
61 public void testJoin1() { | |
62 Stamp aNonNull = StampFactory.declaredNonNull(getType(A.class)); | |
63 Stamp b = StampFactory.declared(getType(B.class)); | |
64 Stamp bNonNull = StampFactory.declaredNonNull(getType(B.class)); | |
65 Assert.assertEquals(bNonNull, join(aNonNull, b)); | |
66 } | |
67 | |
68 @Test | |
69 public void testJoin2() { | |
70 Stamp aExact = StampFactory.exactNonNull(getType(A.class)); | |
71 Stamp b = StampFactory.declared(getType(B.class)); | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11385
diff
changeset
|
72 Assert.assertEquals(StampFactory.illegal(Kind.Object), join(aExact, b)); |
11265 | 73 } |
74 | |
75 @Test | |
76 public void testJoin3() { | |
77 Stamp d = StampFactory.declared(getType(D.class)); | |
78 Stamp c = StampFactory.declared(getType(C.class)); | |
79 Assert.assertTrue(ObjectStamp.isObjectAlwaysNull(join(c, d))); | |
80 } | |
81 | |
82 @Test | |
83 public void testJoin4() { | |
84 Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class)); | |
85 Stamp c = StampFactory.declared(getType(C.class)); | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11385
diff
changeset
|
86 Assert.assertEquals(StampFactory.illegal(Kind.Object), join(c, dExactNonNull)); |
11265 | 87 } |
88 | |
89 @Test | |
90 public void testJoin5() { | |
91 Stamp dExact = StampFactory.exact(getType(D.class)); | |
92 Stamp c = StampFactory.declared(getType(C.class)); | |
93 Assert.assertTrue(ObjectStamp.isObjectAlwaysNull(join(c, dExact))); | |
94 } | |
95 | |
96 @Test | |
97 public void testJoin6() { | |
98 Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class)); | |
99 Stamp allwaysNull = StampFactory.alwaysNull(); | |
100 Stamp join = join(allwaysNull, dExactNonNull); | |
101 Assert.assertFalse(ObjectStamp.isObjectNonNull(join)); | |
102 Assert.assertFalse(ObjectStamp.isObjectAlwaysNull(join)); | |
103 } | |
104 | |
105 @Test | |
106 public void testJoinInterface0() { | |
107 Stamp a = StampFactory.declared(getType(A.class)); | |
108 Stamp b = StampFactory.declared(getType(I.class)); | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11385
diff
changeset
|
109 Assert.assertNotSame(StampFactory.illegal(Kind.Object), join(a, b)); |
11265 | 110 } |
111 | |
112 @Test | |
113 public void testJoinInterface1() { | |
114 Stamp aNonNull = StampFactory.declaredNonNull(getType(A.class)); | |
115 Stamp i = StampFactory.declared(getType(I.class)); | |
116 Stamp join = join(aNonNull, i); | |
117 Assert.assertTrue(join instanceof ObjectStamp); | |
118 Assert.assertTrue(((ObjectStamp) join).nonNull()); | |
119 } | |
120 | |
121 @Test | |
122 public void testJoinInterface2() { | |
123 Stamp bExact = StampFactory.exactNonNull(getType(B.class)); | |
124 Stamp i = StampFactory.declared(getType(I.class)); | |
125 Stamp join = join(i, bExact); | |
11387
9088d13767f3
Keep a kind in the illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11385
diff
changeset
|
126 Assert.assertEquals(StampFactory.illegal(Kind.Object), join); |
11265 | 127 } |
128 | |
129 private static Stamp join(Stamp a, Stamp b) { | |
130 Stamp ab = a.join(b); | |
131 Stamp ba = b.join(a); | |
132 Assert.assertEquals(ab, ba); | |
133 return ab; | |
134 } | |
135 | |
136 private ResolvedJavaType getType(Class<?> clazz) { | |
137 return runtime().lookupJavaType(clazz); | |
138 } | |
139 } |