Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SourceSectionTest.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 static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; | |
26 import static com.oracle.truffle.api.dsl.test.TestHelper.createRootPrefix; | |
27 import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; | |
28 import static org.hamcrest.CoreMatchers.is; | |
29 import static org.hamcrest.CoreMatchers.sameInstance; | |
30 import static org.junit.Assert.assertNull; | |
31 import static org.junit.Assert.assertThat; | |
32 | |
33 import org.junit.After; | |
34 import org.junit.Before; | |
35 import org.junit.Test; | |
36 import org.junit.experimental.theories.DataPoints; | |
37 import org.junit.experimental.theories.Theories; | |
38 import org.junit.experimental.theories.Theory; | |
39 import org.junit.runner.RunWith; | |
40 | |
25 import com.oracle.truffle.api.dsl.CreateCast; | 41 import com.oracle.truffle.api.dsl.CreateCast; |
26 import com.oracle.truffle.api.dsl.Fallback; | 42 import com.oracle.truffle.api.dsl.Fallback; |
27 import com.oracle.truffle.api.dsl.NodeChild; | 43 import com.oracle.truffle.api.dsl.NodeChild; |
28 import com.oracle.truffle.api.dsl.Specialization; | 44 import com.oracle.truffle.api.dsl.Specialization; |
29 import com.oracle.truffle.api.dsl.internal.SpecializationNode; | 45 import com.oracle.truffle.api.dsl.internal.SpecializationNode; |
30 import com.oracle.truffle.api.dsl.test.SourceSectionTestFactory.SourceSection0Factory; | 46 import com.oracle.truffle.api.dsl.test.SourceSectionTestFactory.SourceSection0Factory; |
31 import com.oracle.truffle.api.dsl.test.SourceSectionTestFactory.SourceSection1Factory; | 47 import com.oracle.truffle.api.dsl.test.SourceSectionTestFactory.SourceSection1Factory; |
32 import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot; | |
33 import static com.oracle.truffle.api.dsl.test.TestHelper.createRootPrefix; | |
34 import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith; | |
35 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode; | 48 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode; |
36 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; | 49 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
37 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; | 50 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
51 import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; | |
38 import com.oracle.truffle.api.nodes.Node; | 52 import com.oracle.truffle.api.nodes.Node; |
39 import com.oracle.truffle.api.source.SourceSection; | 53 import com.oracle.truffle.api.source.SourceSection; |
40 import static org.hamcrest.CoreMatchers.is; | |
41 import static org.hamcrest.CoreMatchers.sameInstance; | |
42 import static org.junit.Assert.assertNull; | |
43 import static org.junit.Assert.assertThat; | |
44 import org.junit.Test; | |
45 import org.junit.experimental.theories.DataPoints; | |
46 import org.junit.experimental.theories.Theories; | |
47 import org.junit.experimental.theories.Theory; | |
48 import org.junit.runner.RunWith; | |
49 | 54 |
50 @RunWith(Theories.class) | 55 @RunWith(Theories.class) |
51 public class SourceSectionTest { | 56 public class SourceSectionTest { |
52 | 57 |
53 @DataPoints public static final int[] data = new int[]{1, 2, 3, 4}; | 58 @DataPoints public static final int[] data = new int[]{1, 2, 3, 4}; |
59 | |
60 @Before | |
61 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
62 InstrumentationTestMode.set(true); | |
63 } | |
64 | |
65 @After | |
66 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
67 InstrumentationTestMode.set(false); | |
68 } | |
54 | 69 |
55 @Theory | 70 @Theory |
56 public void testSourceSections(int value0, int value1, int value2) { | 71 public void testSourceSections(int value0, int value1, int value2) { |
57 TestRootNode<SourceSection0> root = createRoot(SourceSection0Factory.getInstance()); | 72 TestRootNode<SourceSection0> root = createRoot(SourceSection0Factory.getInstance()); |
58 SourceSection section = SourceSection.createUnavailable("a", "b"); | 73 SourceSection section = SourceSection.createUnavailable("a", "b"); |