comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.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
31 import java.util.Iterator; 33 import java.util.Iterator;
34
35 import org.junit.After;
32 import org.junit.Assert; 36 import org.junit.Assert;
37 import org.junit.Before;
38
33 import static org.junit.Assert.assertEquals; 39 import static org.junit.Assert.assertEquals;
40
34 import org.junit.Test; 41 import org.junit.Test;
35 42
36 /** 43 /**
37 * <h3>Replacing Nodes at Run Time</h3> 44 * <h3>Replacing Nodes at Run Time</h3>
38 * 45 *
51 * <p> 58 * <p>
52 * The next part of the Truffle API introduction is at {@link com.oracle.truffle.api.test.CallTest}. 59 * The next part of the Truffle API introduction is at {@link com.oracle.truffle.api.test.CallTest}.
53 * </p> 60 * </p>
54 */ 61 */
55 public class ReplaceTest { 62 public class ReplaceTest {
63
64 @Before
65 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
66 InstrumentationTestMode.set(true);
67 }
68
69 @After
70 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
71 InstrumentationTestMode.set(false);
72 }
56 73
57 @Test 74 @Test
58 public void test() { 75 public void test() {
59 TruffleRuntime runtime = Truffle.getRuntime(); 76 TruffleRuntime runtime = Truffle.getRuntime();
60 UnresolvedNode leftChild = new UnresolvedNode("20"); 77 UnresolvedNode leftChild = new UnresolvedNode("20");