comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.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
25 import com.oracle.truffle.api.CallTarget; 25 import com.oracle.truffle.api.CallTarget;
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.RootNode; 29 import com.oracle.truffle.api.nodes.RootNode;
30 import com.oracle.truffle.api.test.utilities.InstrumentationTestMode;
31
32 import org.junit.After;
30 import org.junit.Assert; 33 import org.junit.Assert;
34 import org.junit.Before;
31 import org.junit.Test; 35 import org.junit.Test;
32 36
33 /** 37 /**
34 * <h3>Calling Another Tree</h3> 38 * <h3>Calling Another Tree</h3>
35 * 39 *
43 * The next part of the Truffle API introduction is at 47 * The next part of the Truffle API introduction is at
44 * {@link com.oracle.truffle.api.test.ArgumentsTest}. 48 * {@link com.oracle.truffle.api.test.ArgumentsTest}.
45 * </p> 49 * </p>
46 */ 50 */
47 public class CallTest { 51 public class CallTest {
52
53 @Before
54 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
55 InstrumentationTestMode.set(true);
56 }
57
58 @After
59 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
60 InstrumentationTestMode.set(false);
61 }
48 62
49 @Test 63 @Test
50 public void test() { 64 public void test() {
51 TruffleRuntime runtime = Truffle.getRuntime(); 65 TruffleRuntime runtime = Truffle.getRuntime();
52 CallTarget foo = runtime.createCallTarget(new ConstantRootNode(20)); 66 CallTarget foo = runtime.createCallTarget(new ConstantRootNode(20));