Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.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 |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.oracle.truffle.api.test; | 23 package com.oracle.truffle.api.test; |
24 | 24 |
25 import org.junit.After; | |
26 import org.junit.Assert; | |
27 import org.junit.Before; | |
28 import org.junit.Test; | |
29 | |
25 import com.oracle.truffle.api.CallTarget; | 30 import com.oracle.truffle.api.CallTarget; |
26 import com.oracle.truffle.api.Truffle; | 31 import com.oracle.truffle.api.Truffle; |
27 import com.oracle.truffle.api.TruffleRuntime; | 32 import com.oracle.truffle.api.TruffleRuntime; |
28 import com.oracle.truffle.api.frame.Frame; | 33 import com.oracle.truffle.api.frame.Frame; |
29 import com.oracle.truffle.api.frame.FrameDescriptor; | 34 import com.oracle.truffle.api.frame.FrameDescriptor; |
31 import com.oracle.truffle.api.frame.FrameSlotKind; | 36 import com.oracle.truffle.api.frame.FrameSlotKind; |
32 import com.oracle.truffle.api.frame.FrameSlotTypeException; | 37 import com.oracle.truffle.api.frame.FrameSlotTypeException; |
33 import com.oracle.truffle.api.frame.VirtualFrame; | 38 import com.oracle.truffle.api.frame.VirtualFrame; |
34 import com.oracle.truffle.api.nodes.Node; | 39 import com.oracle.truffle.api.nodes.Node; |
35 import com.oracle.truffle.api.nodes.RootNode; | 40 import com.oracle.truffle.api.nodes.RootNode; |
36 import org.junit.Assert; | 41 import com.oracle.truffle.api.test.utilities.InstrumentationTestMode; |
37 import org.junit.Test; | |
38 | 42 |
39 /** | 43 /** |
40 * <h3>Storing Values in Frame Slots</h3> | 44 * <h3>Storing Values in Frame Slots</h3> |
41 * | 45 * |
42 * <p> | 46 * <p> |
67 * {@link com.oracle.truffle.api.test.FrameSlotTypeSpecializationTest}. | 71 * {@link com.oracle.truffle.api.test.FrameSlotTypeSpecializationTest}. |
68 * </p> | 72 * </p> |
69 */ | 73 */ |
70 public class FrameTest { | 74 public class FrameTest { |
71 | 75 |
76 @Before | |
77 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
78 InstrumentationTestMode.set(true); | |
79 } | |
80 | |
81 @After | |
82 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
83 InstrumentationTestMode.set(false); | |
84 } | |
85 | |
72 @Test | 86 @Test |
73 public void test() { | 87 public void test() throws SecurityException, IllegalArgumentException { |
74 TruffleRuntime runtime = Truffle.getRuntime(); | 88 TruffleRuntime runtime = Truffle.getRuntime(); |
75 FrameDescriptor frameDescriptor = new FrameDescriptor(); | 89 FrameDescriptor frameDescriptor = new FrameDescriptor(); |
76 String varName = "localVar"; | 90 String varName = "localVar"; |
77 FrameSlot slot = frameDescriptor.addFrameSlot(varName, FrameSlotKind.Int); | 91 FrameSlot slot = frameDescriptor.addFrameSlot(varName, FrameSlotKind.Int); |
78 TestRootNode rootNode = new TestRootNode(frameDescriptor, new AssignLocal(slot), new ReadLocal(slot)); | 92 TestRootNode rootNode = new TestRootNode(frameDescriptor, new AssignLocal(slot), new ReadLocal(slot)); |