comparison truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SpecializationGroupingTest.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.dsl.test; 23 package com.oracle.truffle.api.dsl.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.dsl.NodeChild; 31 import com.oracle.truffle.api.dsl.NodeChild;
27 import com.oracle.truffle.api.dsl.Specialization; 32 import com.oracle.truffle.api.dsl.Specialization;
28 import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestElseConnectionBug1Factory; 33 import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestElseConnectionBug1Factory;
29 import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestElseConnectionBug2Factory; 34 import com.oracle.truffle.api.dsl.test.SpecializationGroupingTestFactory.TestElseConnectionBug2Factory;
30 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; 35 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
36 import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode;
31 import com.oracle.truffle.api.frame.VirtualFrame; 37 import com.oracle.truffle.api.frame.VirtualFrame;
32 import com.oracle.truffle.api.nodes.SlowPathException; 38 import com.oracle.truffle.api.nodes.SlowPathException;
33 import org.junit.Assert;
34 import org.junit.Test;
35 39
36 /** 40 /**
37 * Tests execution counts of guards. While we do not make guarantees for guard invocation except for 41 * Tests execution counts of guards. While we do not make guarantees for guard invocation except for
38 * their execution order our implementation reduces the calls to guards as much as possible for the 42 * their execution order our implementation reduces the calls to guards as much as possible for the
39 * generic case. 43 * generic case.
40 */ 44 */
41 public class SpecializationGroupingTest { 45 public class SpecializationGroupingTest {
46
47 @Before
48 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
49 InstrumentationTestMode.set(true);
50 }
51
52 @After
53 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
54 InstrumentationTestMode.set(false);
55 }
42 56
43 @Test 57 @Test
44 public void testElseConnectionBug1() { 58 public void testElseConnectionBug1() {
45 CallTarget target = TestHelper.createCallTarget(TestElseConnectionBug1Factory.create(new GenericInt())); 59 CallTarget target = TestHelper.createCallTarget(TestElseConnectionBug1Factory.create(new GenericInt()));
46 Assert.assertEquals(42, target.call()); 60 Assert.assertEquals(42, target.call());