comparison truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/TruffleToolTest.java @ 22219:1c0f490984d5

Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Wed, 16 Sep 2015 15:36:22 -0700
parents dc83cc1f94f2 3aad794eec0e
children 964e789e17f7
comparison
equal deleted inserted replaced
22160:0599e2df6a9f 22219:1c0f490984d5
22 * or visit www.oracle.com if you need additional information or have any 22 * or visit www.oracle.com if you need additional information or have any
23 * questions. 23 * questions.
24 */ 24 */
25 package com.oracle.truffle.tools.test; 25 package com.oracle.truffle.tools.test;
26 26
27 import com.oracle.truffle.api.instrument.InstrumentationTool;
28 import static org.junit.Assert.assertFalse; 27 import static org.junit.Assert.assertFalse;
29 import static org.junit.Assert.assertTrue; 28 import static org.junit.Assert.assertTrue;
29
30 import org.junit.Test; 30 import org.junit.Test;
31
32 import com.oracle.truffle.api.instrument.InstrumentationTool;
33 import com.oracle.truffle.api.instrument.Instrumenter;
31 34
32 /** 35 /**
33 * Test the basic life cycle properties shared by all instances of {@link InstrumentationTool}. 36 * Test the basic life cycle properties shared by all instances of {@link InstrumentationTool}.
34 */ 37 */
35 public class TruffleToolTest { 38 public class TruffleToolTest {
36 39
37 @Test 40 @Test
38 public void testEmptyLifeCycle() { 41 public void testEmptyLifeCycle() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
42 final Instrumenter instrumenter = TestNodes.createInstrumenter();
39 final DummyTruffleTool tool = new DummyTruffleTool(); 43 final DummyTruffleTool tool = new DummyTruffleTool();
40 assertFalse(tool.isEnabled()); 44 assertFalse(tool.isEnabled());
41 tool.install(); 45 tool.install(instrumenter);
42 assertTrue(tool.isEnabled()); 46 assertTrue(tool.isEnabled());
43 tool.reset(); 47 tool.reset();
44 assertTrue(tool.isEnabled()); 48 assertTrue(tool.isEnabled());
45 tool.setEnabled(false); 49 tool.setEnabled(false);
46 assertFalse(tool.isEnabled()); 50 assertFalse(tool.isEnabled());
71 final DummyTruffleTool tool = new DummyTruffleTool(); 75 final DummyTruffleTool tool = new DummyTruffleTool();
72 tool.dispose(); 76 tool.dispose();
73 } 77 }
74 78
75 @Test(expected = IllegalStateException.class) 79 @Test(expected = IllegalStateException.class)
76 public void testAlreadyInstalled() { 80 public void testAlreadyInstalled() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
81 final Instrumenter instrumenter = TestNodes.createInstrumenter();
77 final DummyTruffleTool tool = new DummyTruffleTool(); 82 final DummyTruffleTool tool = new DummyTruffleTool();
78 tool.install(); 83 tool.install(instrumenter);
79 tool.install(); 84 tool.install(instrumenter);
80 } 85 }
81 86
82 @Test(expected = IllegalStateException.class) 87 @Test(expected = IllegalStateException.class)
83 public void testAlreadyDisposed1() { 88 public void testAlreadyDisposed1() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
89 final Instrumenter instrumenter = TestNodes.createInstrumenter();
84 final DummyTruffleTool tool = new DummyTruffleTool(); 90 final DummyTruffleTool tool = new DummyTruffleTool();
85 tool.install(); 91 tool.install(instrumenter);
86 tool.dispose(); 92 tool.dispose();
87 tool.install(); 93 tool.install(instrumenter);
88 } 94 }
89 95
90 @Test(expected = IllegalStateException.class) 96 @Test(expected = IllegalStateException.class)
91 public void testAlreadyDisposed2() { 97 public void testAlreadyDisposed2() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
98 final Instrumenter instrumenter = TestNodes.createInstrumenter();
92 final DummyTruffleTool tool = new DummyTruffleTool(); 99 final DummyTruffleTool tool = new DummyTruffleTool();
93 tool.install(); 100 tool.install(instrumenter);
94 tool.dispose(); 101 tool.dispose();
95 tool.reset(); 102 tool.reset();
96 } 103 }
97 104
98 @Test(expected = IllegalStateException.class) 105 @Test(expected = IllegalStateException.class)
99 public void testAlreadyDisposed3() { 106 public void testAlreadyDisposed3() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
107 final Instrumenter instrumenter = TestNodes.createInstrumenter();
100 final DummyTruffleTool tool = new DummyTruffleTool(); 108 final DummyTruffleTool tool = new DummyTruffleTool();
101 tool.install(); 109 tool.install(instrumenter);
102 tool.dispose(); 110 tool.dispose();
103 tool.setEnabled(true); 111 tool.setEnabled(true);
104 } 112 }
105 113
106 @Test(expected = IllegalStateException.class) 114 @Test(expected = IllegalStateException.class)
107 public void testAlreadyDisposed4() { 115 public void testAlreadyDisposed4() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
116 final Instrumenter instrumenter = TestNodes.createInstrumenter();
108 final DummyTruffleTool tool = new DummyTruffleTool(); 117 final DummyTruffleTool tool = new DummyTruffleTool();
109 tool.install(); 118 tool.install(instrumenter);
110 tool.dispose(); 119 tool.dispose();
111 tool.dispose(); 120 tool.dispose();
112 } 121 }
113 122
114 private static final class DummyTruffleTool extends InstrumentationTool { 123 private static final class DummyTruffleTool extends InstrumentationTool {