comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java @ 22241:14e6dfb1ef05

Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation" - Caused by lack of a "vm" known to the Accessor during most testing, making the Instrumenter unavailable, which is now required to create a CallTarget - Modified the Instrumenter/Accessor with a static field that can be reflectively "poked" with a vm value for testing - Create a pair of methods to globally enable/disable testing mode to modify that static field and restore it when tests complete.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 22 Sep 2015 20:31:19 -0700
parents dc83cc1f94f2
children 0d36601f233e
comparison
equal deleted inserted replaced
22240:f78c72e2e0b6 22241:14e6dfb1ef05
26 import com.oracle.truffle.api.Truffle; 26 import com.oracle.truffle.api.Truffle;
27 import com.oracle.truffle.api.TruffleRuntime; 27 import com.oracle.truffle.api.TruffleRuntime;
28 import com.oracle.truffle.api.frame.VirtualFrame; 28 import com.oracle.truffle.api.frame.VirtualFrame;
29 import com.oracle.truffle.api.nodes.Node; 29 import com.oracle.truffle.api.nodes.Node;
30 import com.oracle.truffle.api.nodes.RootNode; 30 import com.oracle.truffle.api.nodes.RootNode;
31 import com.oracle.truffle.api.test.utilities.InstrumentationTestMode;
32
33 import org.junit.After;
31 import org.junit.Assert; 34 import org.junit.Assert;
35 import org.junit.Before;
32 import org.junit.Test; 36 import org.junit.Test;
33 37
34 /** 38 /**
35 * <h3>Using Final Fields in Node Classes</h3> 39 * <h3>Using Final Fields in Node Classes</h3>
36 * 40 *
51 * The next part of the Truffle API introduction is at 55 * The next part of the Truffle API introduction is at
52 * {@link com.oracle.truffle.api.test.ReplaceTest}. 56 * {@link com.oracle.truffle.api.test.ReplaceTest}.
53 * </p> 57 * </p>
54 */ 58 */
55 public class FinalFieldTest { 59 public class FinalFieldTest {
60
61 @Before
62 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
63 InstrumentationTestMode.set(true);
64 }
65
66 @After
67 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
68 InstrumentationTestMode.set(false);
69 }
56 70
57 @Test 71 @Test
58 public void test() { 72 public void test() {
59 TruffleRuntime runtime = Truffle.getRuntime(); 73 TruffleRuntime runtime = Truffle.getRuntime();
60 TestRootNode rootNode = new TestRootNode(new TestChildNode[]{new TestChildNode(20), new TestChildNode(22)}); 74 TestRootNode rootNode = new TestRootNode(new TestChildNode[]{new TestChildNode(20), new TestChildNode(22)});