Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/NeverValidAssumptionTest.java @ 19050:75da87c96605
initial commit of GraphBuilderPhase plugins
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 31 Jan 2015 00:30:00 +0100 |
parents | e9c8742148c1 |
children |
rev | line source |
---|---|
17057
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
1 /* |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
4 * |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
8 * |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
14 * |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
18 * |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
21 * questions. |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
22 */ |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.test.utilities; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
24 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
25 import static org.junit.Assert.*; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
26 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
27 import org.junit.*; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
28 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.nodes.*; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.utilities.*; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
31 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
32 public class NeverValidAssumptionTest { |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
33 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
34 @Test |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
35 public void testCheck() { |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
36 final NeverValidAssumption assumption = NeverValidAssumption.INSTANCE; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
37 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
38 try { |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
39 assumption.check(); |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
40 fail(); |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
41 } catch (InvalidAssumptionException e) { |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
42 } catch (Exception e) { |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
43 fail(); |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
44 } |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
45 } |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
46 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
47 @Test |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
48 public void testIsValid() { |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
49 final NeverValidAssumption assumption = NeverValidAssumption.INSTANCE; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
50 assertFalse(assumption.isValid()); |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
51 } |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
52 |
17439
e9c8742148c1
Truffle: NeverValidAssumption can be invalidated.
Chris Seaton <chris.seaton@oracle.com>
parents:
17057
diff
changeset
|
53 @Test |
e9c8742148c1
Truffle: NeverValidAssumption can be invalidated.
Chris Seaton <chris.seaton@oracle.com>
parents:
17057
diff
changeset
|
54 public void testInvalidateDoesNothing() { |
17057
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
55 final NeverValidAssumption assumption = NeverValidAssumption.INSTANCE; |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
56 assumption.invalidate(); |
17439
e9c8742148c1
Truffle: NeverValidAssumption can be invalidated.
Chris Seaton <chris.seaton@oracle.com>
parents:
17057
diff
changeset
|
57 assumption.invalidate(); |
e9c8742148c1
Truffle: NeverValidAssumption can be invalidated.
Chris Seaton <chris.seaton@oracle.com>
parents:
17057
diff
changeset
|
58 assumption.invalidate(); |
17057
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
59 } |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
60 |
d51c097cca37
Truffle: Add NeverValidAssumption.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
61 } |