comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.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
31 import com.oracle.truffle.api.frame.FrameSlotTypeException; 31 import com.oracle.truffle.api.frame.FrameSlotTypeException;
32 import com.oracle.truffle.api.frame.VirtualFrame; 32 import com.oracle.truffle.api.frame.VirtualFrame;
33 import com.oracle.truffle.api.nodes.Node; 33 import com.oracle.truffle.api.nodes.Node;
34 import com.oracle.truffle.api.nodes.RootNode; 34 import com.oracle.truffle.api.nodes.RootNode;
35 import com.oracle.truffle.api.nodes.UnexpectedResultException; 35 import com.oracle.truffle.api.nodes.UnexpectedResultException;
36 import com.oracle.truffle.api.test.utilities.InstrumentationTestMode;
37
38 import org.junit.After;
36 import org.junit.Assert; 39 import org.junit.Assert;
40 import org.junit.Before;
37 import org.junit.Test; 41 import org.junit.Test;
38 42
39 /** 43 /**
40 * <h3>Specializing Return Types</h3> 44 * <h3>Specializing Return Types</h3>
41 * 45 *
49 * order to avoid future failures of this kind. 53 * order to avoid future failures of this kind.
50 * </p> 54 * </p>
51 */ 55 */
52 public class ReturnTypeSpecializationTest { 56 public class ReturnTypeSpecializationTest {
53 57
58 @Before
59 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
60 InstrumentationTestMode.set(true);
61 }
62
63 @After
64 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
65 InstrumentationTestMode.set(false);
66 }
67
54 @Test 68 @Test
55 public void test() { 69 public void test() {
56 TruffleRuntime runtime = Truffle.getRuntime(); 70 TruffleRuntime runtime = Truffle.getRuntime();
57 FrameDescriptor frameDescriptor = new FrameDescriptor(); 71 FrameDescriptor frameDescriptor = new FrameDescriptor();
58 FrameSlot slot = frameDescriptor.addFrameSlot("localVar", FrameSlotKind.Int); 72 FrameSlot slot = frameDescriptor.addFrameSlot("localVar", FrameSlotKind.Int);