comparison truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.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 5309cc9668e3
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.dsl.test; 23 package com.oracle.truffle.api.dsl.test;
24 24
25 import static com.oracle.truffle.api.dsl.test.TestHelper.assertionsEnabled;
26 import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget;
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.fail;
29
30 import org.junit.After;
31 import org.junit.Before;
32 import org.junit.Test;
33
25 import com.oracle.truffle.api.CallTarget; 34 import com.oracle.truffle.api.CallTarget;
26 import com.oracle.truffle.api.dsl.Cached; 35 import com.oracle.truffle.api.dsl.Cached;
27 import com.oracle.truffle.api.dsl.NodeChild; 36 import com.oracle.truffle.api.dsl.NodeChild;
28 import com.oracle.truffle.api.dsl.NodeChildren; 37 import com.oracle.truffle.api.dsl.NodeChildren;
29 import com.oracle.truffle.api.dsl.NodeField; 38 import com.oracle.truffle.api.dsl.NodeField;
37 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCacheNodeFieldFactory; 46 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCacheNodeFieldFactory;
38 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithCachedAndDynamicParameterFactory; 47 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithCachedAndDynamicParameterFactory;
39 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithJustCachedParameterFactory; 48 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithJustCachedParameterFactory;
40 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestMultipleCachesFactory; 49 import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestMultipleCachesFactory;
41 import com.oracle.truffle.api.dsl.test.CachedTestFactory.UnboundCacheFactory; 50 import com.oracle.truffle.api.dsl.test.CachedTestFactory.UnboundCacheFactory;
42 import static com.oracle.truffle.api.dsl.test.TestHelper.assertionsEnabled;
43 import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget;
44 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; 51 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
45 import static org.junit.Assert.assertEquals; 52 import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode;
46 import static org.junit.Assert.fail;
47 import org.junit.Test;
48 53
49 @SuppressWarnings("unused") 54 @SuppressWarnings("unused")
50 public class CachedTest { 55 public class CachedTest {
56
57 @Before
58 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
59 InstrumentationTestMode.set(true);
60 }
61
62 @After
63 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
64 InstrumentationTestMode.set(false);
65 }
51 66
52 @Test 67 @Test
53 public void testUnboundCache() { 68 public void testUnboundCache() {
54 CallTarget root = createCallTarget(UnboundCacheFactory.getInstance()); 69 CallTarget root = createCallTarget(UnboundCacheFactory.getInstance());
55 assertEquals(42, root.call(42)); 70 assertEquals(42, root.call(42));