annotate graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/ObjectStampJoinTest.java @ 21556:48c1ebd24120

renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 00:36:16 +0200
parents 9a7125f0eeda
children 4f88bd1dbc61
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
4 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
8 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
14 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
18 *
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
21 * questions.
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
22 */
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
23 package com.oracle.graal.nodes.test;
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
24
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21212
diff changeset
25 import com.oracle.jvmci.meta.Kind;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
26 import org.junit.*;
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
27
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 14997
diff changeset
28 import com.oracle.graal.compiler.common.type.*;
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
29 import com.oracle.graal.nodes.type.*;
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
30
17156
ac6e25901d62 Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15660
diff changeset
31 public class ObjectStampJoinTest extends AbstractObjectStampTest {
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
32
15660
9c75a5e29052 tests for ObjectStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15524
diff changeset
33 // class A
9c75a5e29052 tests for ObjectStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15524
diff changeset
34 // class B extends A
9c75a5e29052 tests for ObjectStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15524
diff changeset
35 // class C extends B implements I
9c75a5e29052 tests for ObjectStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15524
diff changeset
36 // class D extends A
9c75a5e29052 tests for ObjectStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15524
diff changeset
37 // abstract class E extends A
9c75a5e29052 tests for ObjectStamp.meet
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15524
diff changeset
38 // interface I
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
39
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
40 @Test
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
41 public void testJoin0() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
42 Stamp a = StampFactory.declared(getType(A.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
43 Stamp b = StampFactory.declared(getType(B.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
44 Assert.assertEquals(b, join(a, b));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
45 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
46
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
47 @Test
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
48 public void testJoin1() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
49 Stamp aNonNull = StampFactory.declaredNonNull(getType(A.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
50 Stamp b = StampFactory.declared(getType(B.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
51 Stamp bNonNull = StampFactory.declaredNonNull(getType(B.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
52 Assert.assertEquals(bNonNull, join(aNonNull, b));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
53 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
54
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
55 @Test
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
56 public void testJoin2() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
57 Stamp aExact = StampFactory.exactNonNull(getType(A.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
58 Stamp b = StampFactory.declared(getType(B.class));
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
59 Assert.assertEquals(StampFactory.empty(Kind.Object), join(aExact, b));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
60 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
61
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
62 @Test
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
63 public void testJoin3() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
64 Stamp d = StampFactory.declared(getType(D.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
65 Stamp c = StampFactory.declared(getType(C.class));
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
66 Assert.assertTrue(StampTool.isPointerAlwaysNull(join(c, d)));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
67 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
68
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
69 @Test
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
70 public void testJoin4() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
71 Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
72 Stamp c = StampFactory.declared(getType(C.class));
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
73 Assert.assertEquals(StampFactory.empty(Kind.Object), join(c, dExactNonNull));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
74 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
75
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
76 @Test
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
77 public void testJoin5() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
78 Stamp dExact = StampFactory.exact(getType(D.class));
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
79 Stamp c = StampFactory.declared(getType(C.class));
11394
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
80 Stamp join = join(c, dExact);
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
81 Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
82 Assert.assertNull(StampTool.typeOrNull(join));
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
83 Assert.assertFalse(StampTool.isExactType(join));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
84 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
85
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
86 @Test
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
87 public void testJoin6() {
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
88 Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class));
14997
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 11959
diff changeset
89 Stamp alwaysNull = StampFactory.alwaysNull();
5e4ae8709830 Use typed illegal stamps and use IllegalStamp only for conflicting primitive types.
Roland Schatz <roland.schatz@oracle.com>
parents: 11959
diff changeset
90 Stamp join = join(alwaysNull, dExactNonNull);
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
91 Assert.assertFalse(join.hasValues());
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
92 Assert.assertFalse(StampTool.isPointerNonNull(join));
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
93 Assert.assertFalse(StampTool.isPointerAlwaysNull(join));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
94 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
95
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
96 @Test
11394
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
97 public void testJoin7() {
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
98 Stamp aExact = StampFactory.exact(getType(A.class));
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
99 Stamp e = StampFactory.declared(getType(E.class));
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
100 Stamp join = join(aExact, e);
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
101 Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
15260
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
102 Assert.assertNull(StampTool.typeOrNull(join));
61363577a184 Move static helpers from ObjectStamp to StampTool.
Josef Eisl <josef.eisl@jku.at>
parents: 15198
diff changeset
103 Assert.assertFalse(StampTool.isExactType(join));
11394
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
104 }
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
105
40c7cbe31aa9 Simplify ObjectStamp.join and make sure there is no type/exact type when going to an allways null stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11387
diff changeset
106 @Test
15524
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
107 public void testJoin8() {
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
108 Stamp bExact = StampFactory.exactNonNull(getType(B.class));
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
109 Stamp dExact = StampFactory.exact(getType(D.class));
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
110 Stamp join = join(bExact, dExact);
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
111 Assert.assertFalse(join.hasValues());
15524
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
112 }
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
113
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
114 @Test
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
115 public void testJoin9() {
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
116 Stamp bExact = StampFactory.exact(getType(B.class));
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
117 Stamp dExact = StampFactory.exact(getType(D.class));
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
118 Stamp join = join(bExact, dExact);
18490
ca81508f2a19 Generalize NULL handling to work on arbitrary pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 18416
diff changeset
119 Assert.assertTrue(StampTool.isPointerAlwaysNull(join));
15524
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
120 Assert.assertNull(StampTool.typeOrNull(join));
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
121 Assert.assertNull(StampTool.typeOrNull(join));
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
122 }
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
123
901b4440a451 Add two more ObjectStampJoinTest unit tests.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15260
diff changeset
124 @Test
21212
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
125 public void testJoinInterfaceSimple() {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
126 // Tests joining of interface
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
127 testJoinInterface(A.class, B.class, I.class);
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
128 }
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
129
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
130 @Test
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
131 public void testJoinInterfaceArray() {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
132 // Tests joining of arrays interface
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
133 testJoinInterface(A[].class, B[].class, I[].class);
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
134 }
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
135
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
136 @Test
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
137 public void testJoinInterfaceMultiArray() {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
138 // Tests joining of multidimensional arrays of interface
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
139 testJoinInterface(A[][].class, B[][].class, I[][].class);
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
140 }
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
141
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
142 private void testJoinInterface(Class<?> typeA, Class<?> typeB, Class<?> typeI) {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
143 testJoinInterface0(typeA, typeI);
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
144 testJoinInterface1(typeA, typeI);
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
145 testJoinInterface2(typeB, typeI);
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
146 testJoinInterface3(typeB, typeI);
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
147 }
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
148
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
149 private void testJoinInterface0(Class<?> typeA, Class<?> typeI) {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
150 Stamp a = StampFactory.declared(getType(typeA));
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
151 Stamp i = StampFactory.declaredTrusted(getType(typeI));
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
152 Assert.assertNotSame(StampFactory.empty(Kind.Object), join(a, i));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
153 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
154
21212
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
155 private void testJoinInterface1(Class<?> typeA, Class<?> typeI) {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
156 Stamp aNonNull = StampFactory.declaredNonNull(getType(typeA));
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
157 Stamp i = StampFactory.declaredTrusted(getType(typeI));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
158 Stamp join = join(aNonNull, i);
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
159 Assert.assertTrue(join instanceof ObjectStamp);
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
160 Assert.assertTrue(((ObjectStamp) join).nonNull());
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
161 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
162
21212
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
163 private void testJoinInterface2(Class<?> typeB, Class<?> typeI) {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
164 Stamp bExact = StampFactory.exactNonNull(getType(typeB));
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
165 Stamp i = StampFactory.declaredTrusted(getType(typeI));
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
166 Stamp join = join(i, bExact);
20928
35e1b66f2810 Rename Stamp.illegal() to Stamp.empty().
Roland Schatz <roland.schatz@oracle.com>
parents: 18490
diff changeset
167 Assert.assertEquals(StampFactory.empty(Kind.Object), join);
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
168 }
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
169
21212
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
170 private void testJoinInterface3(Class<?> typeB, Class<?> typeI) {
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
171 Stamp bExact = StampFactory.exactNonNull(getType(typeB));
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
172 Stamp i = StampFactory.declared(getType(typeI)); // not trusted
17156
ac6e25901d62 Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15660
diff changeset
173 Stamp join = join(i, bExact);
ac6e25901d62 Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15660
diff changeset
174 Assert.assertEquals(bExact, join);
ac6e25901d62 Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15660
diff changeset
175 }
21212
9a7125f0eeda Add test for arrays of interface
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 20928
diff changeset
176
11265
ef6915cf1e59 Add illegal stamp
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
177 }