Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/UnionAssumptionTest.java @ 21640:11f68b116a07
mx: added support for server-nograal and client-nograal aliases
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 18:04:12 +0200 |
parents | f28ea693056f |
children |
rev | line source |
---|---|
13325
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
1 /* |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
4 * |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
8 * |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
14 * |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
18 * |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
21 * questions. |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
22 */ |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.test.utilities; |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
24 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
25 import static org.junit.Assert.*; |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
26 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
27 import org.junit.*; |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
28 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.*; |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.nodes.*; |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.utilities.*; |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
32 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
33 public class UnionAssumptionTest { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
34 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
35 @Test |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
36 public void testIsValid() { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
37 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
38 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
39 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
40 assertTrue(union.isValid()); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
41 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
42 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
43 @Test |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
44 public void testCheck() throws InvalidAssumptionException { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
45 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
46 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
47 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
48 union.check(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
49 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
50 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
51 @Test |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
52 public void testFirstInvalidateIsValid() { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
53 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
54 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
55 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
56 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
57 first.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
58 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
59 assertFalse(union.isValid()); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
60 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
61 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
62 @Test(expected = InvalidAssumptionException.class) |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
63 public void testFirstInvalidateCheck() throws InvalidAssumptionException { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
64 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
65 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
66 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
67 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
68 first.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
69 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
70 union.check(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
71 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
72 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
73 @Test |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
74 public void testSecondInvalidateIsValid() { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
75 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
76 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
77 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
78 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
79 second.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
80 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
81 assertFalse(union.isValid()); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
82 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
83 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
84 @Test(expected = InvalidAssumptionException.class) |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
85 public void testSecondInvalidateCheck() throws InvalidAssumptionException { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
86 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
87 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
88 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
89 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
90 second.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
91 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
92 union.check(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
93 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
94 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
95 @Test |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
96 public void testBothInvalidateIsValid() { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
97 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
98 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
99 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
100 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
101 first.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
102 second.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
103 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
104 assertFalse(union.isValid()); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
105 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
106 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
107 @Test(expected = InvalidAssumptionException.class) |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
108 public void testBothInvalidateCheck() throws InvalidAssumptionException { |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
109 final Assumption first = Truffle.getRuntime().createAssumption("first"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
110 final Assumption second = Truffle.getRuntime().createAssumption("second"); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
111 final UnionAssumption union = new UnionAssumption(first, second); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
112 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
113 first.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
114 second.invalidate(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
115 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
116 union.check(); |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
117 } |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
118 |
f28ea693056f
New assumption utilities.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
119 } |