Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/UnionAssumptionTest.java @ 13325:f28ea693056f
New assumption utilities.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Fri, 13 Dec 2013 15:53:30 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13324:e585ac5a385d | 13325:f28ea693056f |
---|---|
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.truffle.api.test.utilities; | |
24 | |
25 import static org.junit.Assert.*; | |
26 | |
27 import org.junit.*; | |
28 | |
29 import com.oracle.truffle.api.*; | |
30 import com.oracle.truffle.api.nodes.*; | |
31 import com.oracle.truffle.api.utilities.*; | |
32 | |
33 public class UnionAssumptionTest { | |
34 | |
35 @Test | |
36 public void testIsValid() { | |
37 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
38 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
39 final UnionAssumption union = new UnionAssumption(first, second); | |
40 assertTrue(union.isValid()); | |
41 } | |
42 | |
43 @Test | |
44 public void testCheck() throws InvalidAssumptionException { | |
45 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
46 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
47 final UnionAssumption union = new UnionAssumption(first, second); | |
48 union.check(); | |
49 } | |
50 | |
51 @Test | |
52 public void testFirstInvalidateIsValid() { | |
53 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
54 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
55 final UnionAssumption union = new UnionAssumption(first, second); | |
56 | |
57 first.invalidate(); | |
58 | |
59 assertFalse(union.isValid()); | |
60 } | |
61 | |
62 @Test(expected = InvalidAssumptionException.class) | |
63 public void testFirstInvalidateCheck() throws InvalidAssumptionException { | |
64 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
65 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
66 final UnionAssumption union = new UnionAssumption(first, second); | |
67 | |
68 first.invalidate(); | |
69 | |
70 union.check(); | |
71 } | |
72 | |
73 @Test | |
74 public void testSecondInvalidateIsValid() { | |
75 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
76 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
77 final UnionAssumption union = new UnionAssumption(first, second); | |
78 | |
79 second.invalidate(); | |
80 | |
81 assertFalse(union.isValid()); | |
82 } | |
83 | |
84 @Test(expected = InvalidAssumptionException.class) | |
85 public void testSecondInvalidateCheck() throws InvalidAssumptionException { | |
86 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
87 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
88 final UnionAssumption union = new UnionAssumption(first, second); | |
89 | |
90 second.invalidate(); | |
91 | |
92 union.check(); | |
93 } | |
94 | |
95 @Test | |
96 public void testBothInvalidateIsValid() { | |
97 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
98 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
99 final UnionAssumption union = new UnionAssumption(first, second); | |
100 | |
101 first.invalidate(); | |
102 second.invalidate(); | |
103 | |
104 assertFalse(union.isValid()); | |
105 } | |
106 | |
107 @Test(expected = InvalidAssumptionException.class) | |
108 public void testBothInvalidateCheck() throws InvalidAssumptionException { | |
109 final Assumption first = Truffle.getRuntime().createAssumption("first"); | |
110 final Assumption second = Truffle.getRuntime().createAssumption("second"); | |
111 final UnionAssumption union = new UnionAssumption(first, second); | |
112 | |
113 first.invalidate(); | |
114 second.invalidate(); | |
115 | |
116 union.check(); | |
117 } | |
118 | |
119 } |