Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/tools/TruffleToolTest.java @ 18988:cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 27 Jan 2015 20:27:25 -0800 |
parents | |
children | 3d2296dbace9 |
comparison
equal
deleted
inserted
replaced
18987:ac114ad31cdd | 18988:cca166aa28c0 |
---|---|
1 /* | |
2 * Copyright (c) 2015, 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.tools; | |
24 | |
25 import static org.junit.Assert.*; | |
26 | |
27 import org.junit.*; | |
28 | |
29 import com.oracle.truffle.api.instrument.*; | |
30 | |
31 /** | |
32 * Test the basic life cycle properties shared by all instances of {@link TruffleTool}. | |
33 */ | |
34 public class TruffleToolTest { | |
35 | |
36 @Test | |
37 public void testEmptyLifeCycle() { | |
38 final DummyTruffleTool tool = new DummyTruffleTool(); | |
39 assertFalse(tool.isEnabled()); | |
40 tool.install(); | |
41 assertTrue(tool.isEnabled()); | |
42 tool.reset(); | |
43 assertTrue(tool.isEnabled()); | |
44 tool.setEnabled(false); | |
45 assertFalse(tool.isEnabled()); | |
46 tool.reset(); | |
47 assertFalse(tool.isEnabled()); | |
48 tool.setEnabled(true); | |
49 assertTrue(tool.isEnabled()); | |
50 tool.reset(); | |
51 assertTrue(tool.isEnabled()); | |
52 tool.dispose(); | |
53 assertFalse(tool.isEnabled()); | |
54 } | |
55 | |
56 @Test(expected = IllegalStateException.class) | |
57 public void testNotYetInstalled1() { | |
58 final DummyTruffleTool tool = new DummyTruffleTool(); | |
59 tool.reset(); | |
60 } | |
61 | |
62 @Test(expected = IllegalStateException.class) | |
63 public void testNotYetInstalled2() { | |
64 final DummyTruffleTool tool = new DummyTruffleTool(); | |
65 tool.setEnabled(true); | |
66 } | |
67 | |
68 @Test(expected = IllegalStateException.class) | |
69 public void testNotYetInstalled3() { | |
70 final DummyTruffleTool tool = new DummyTruffleTool(); | |
71 tool.dispose(); | |
72 } | |
73 | |
74 @Test(expected = IllegalStateException.class) | |
75 public void testAlreadyInstalled() { | |
76 final DummyTruffleTool tool = new DummyTruffleTool(); | |
77 tool.install(); | |
78 tool.install(); | |
79 } | |
80 | |
81 @Test(expected = IllegalStateException.class) | |
82 public void testAlreadyDisposed1() { | |
83 final DummyTruffleTool tool = new DummyTruffleTool(); | |
84 tool.install(); | |
85 tool.dispose(); | |
86 tool.install(); | |
87 } | |
88 | |
89 @Test(expected = IllegalStateException.class) | |
90 public void testAlreadyDisposed2() { | |
91 final DummyTruffleTool tool = new DummyTruffleTool(); | |
92 tool.install(); | |
93 tool.dispose(); | |
94 tool.reset(); | |
95 } | |
96 | |
97 @Test(expected = IllegalStateException.class) | |
98 public void testAlreadyDisposed3() { | |
99 final DummyTruffleTool tool = new DummyTruffleTool(); | |
100 tool.install(); | |
101 tool.dispose(); | |
102 tool.setEnabled(true); | |
103 } | |
104 | |
105 @Test(expected = IllegalStateException.class) | |
106 public void testAlreadyDisposed4() { | |
107 final DummyTruffleTool tool = new DummyTruffleTool(); | |
108 tool.install(); | |
109 tool.dispose(); | |
110 tool.dispose(); | |
111 } | |
112 | |
113 private static final class DummyTruffleTool extends TruffleTool { | |
114 | |
115 @Override | |
116 protected boolean internalInstall() { | |
117 return true; | |
118 } | |
119 | |
120 @Override | |
121 protected void internalReset() { | |
122 } | |
123 | |
124 @Override | |
125 protected void internalDispose() { | |
126 } | |
127 | |
128 } | |
129 } |