# HG changeset patch # User Michael Van De Vanter # Date 1442694341 25200 # Node ID 69156ed8192b10d1495ecd23731196e171146324 # Parent c92d6117696f4c3e4f2c6dcc8a5d22df729af52c Truffle/Instrumentation: rewrite basic instrumentation tests diff -r c92d6117696f -r 69156ed8192b mx.truffle/suite.py --- a/mx.truffle/suite.py Sat Sep 19 13:24:47 2015 -0700 +++ b/mx.truffle/suite.py Sat Sep 19 13:25:41 2015 -0700 @@ -193,6 +193,7 @@ ], "checkstyle" : "com.oracle.truffle.api", "javaCompliance" : "1.7", + "annotationProcessors" : ["TRUFFLE_DSL_PROCESSOR"], "workingSets" : "Truffle,Tools", }, diff -r c92d6117696f -r 69156ed8192b truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/AdvancedInstrumentTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/AdvancedInstrumentTest.java Sat Sep 19 13:24:47 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/AdvancedInstrumentTest.java Sat Sep 19 13:25:41 2015 -0700 @@ -22,7 +22,6 @@ */ package com.oracle.truffle.api.test.instrument; -import static com.oracle.truffle.api.test.instrument.InstrumentationTestingLanguage.ADD_TAG; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -42,6 +41,7 @@ import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestAdvancedInstrumentCounterRoot; +import com.oracle.truffle.api.test.instrument.InstrumentationTestingLanguage.InstrumentTestTag; import com.oracle.truffle.api.vm.TruffleVM; /** @@ -69,7 +69,7 @@ } public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) { - if (tag == ADD_TAG) { + if (tag == InstrumentTestTag.ADD_TAG) { assertNull("only one add node", addNodeProbe[0]); addNodeProbe[0] = probe; } diff -r c92d6117696f -r 69156ed8192b truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java Sat Sep 19 13:24:47 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java Sat Sep 19 13:25:41 2015 -0700 @@ -22,8 +22,6 @@ */ package com.oracle.truffle.api.test.instrument; -import static com.oracle.truffle.api.test.instrument.InstrumentationTestingLanguage.ADD_TAG; -import static com.oracle.truffle.api.test.instrument.InstrumentationTestingLanguage.VALUE_TAG; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -53,6 +51,7 @@ import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestAdditionNode; import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestLanguageNode; import com.oracle.truffle.api.test.instrument.InstrumentationTestNodes.TestValueNode; +import com.oracle.truffle.api.test.instrument.InstrumentationTestingLanguage.InstrumentTestTag; import com.oracle.truffle.api.vm.TruffleVM; /** @@ -93,10 +92,10 @@ } public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) { - if (tag == ADD_TAG) { + if (tag == InstrumentTestTag.ADD_TAG) { assertEquals(probes[0], null); probes[0] = probe; - } else if (tag == VALUE_TAG) { + } else if (tag == InstrumentTestTag.VALUE_TAG) { if (probes[1] == null) { probes[1] = probe; } else if (probes[2] == null) { @@ -147,8 +146,8 @@ assertEquals(probeListener.probeCount, 3); assertEquals(probeListener.tagCount, 3); - assertEquals(instrumenter.findProbesTaggedAs(InstrumentationTestingLanguage.ADD_TAG).size(), 1); - assertEquals(instrumenter.findProbesTaggedAs(VALUE_TAG).size(), 2); + assertEquals(instrumenter.findProbesTaggedAs(InstrumentTestTag.ADD_TAG).size(), 1); + assertEquals(instrumenter.findProbesTaggedAs(InstrumentTestTag.VALUE_TAG).size(), 2); } private static void checkCounters(Probe probe, TruffleVM vm, Source source, TestCounter counterA, TestCounter counterB, TestCounter counterC) throws IOException { @@ -346,10 +345,10 @@ final TestLanguageNode testNode = (TestLanguageNode) node; if (node instanceof TestValueNode) { - instrumenter.probe(testNode).tagAs(VALUE_TAG, null); + instrumenter.probe(testNode).tagAs(InstrumentTestTag.VALUE_TAG, null); } else if (node instanceof TestAdditionNode) { - instrumenter.probe(testNode).tagAs(ADD_TAG, null); + instrumenter.probe(testNode).tagAs(InstrumentTestTag.ADD_TAG, null); } } diff -r c92d6117696f -r 69156ed8192b truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestingLanguage.java --- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestingLanguage.java Sat Sep 19 13:24:47 2015 -0700 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTestingLanguage.java Sat Sep 19 13:25:41 2015 -0700 @@ -52,31 +52,28 @@ public static final InstrumentationTestingLanguage INSTANCE = new InstrumentationTestingLanguage(); - public static final SyntaxTag ADD_TAG = new SyntaxTag() { + static enum InstrumentTestTag implements SyntaxTag { + + ADD_TAG("addition", "test language addition node"), + + VALUE_TAG("value", "test language value node"); - @Override - public String name() { - return "Addition"; + private final String name; + private final String description; + + private InstrumentTestTag(String name, String description) { + this.name = name; + this.description = description; } - @Override - public String getDescription() { - return "Test Language Addition Node"; - } - }; - - public static final SyntaxTag VALUE_TAG = new SyntaxTag() { - - @Override - public String name() { - return "Value"; + public String getName() { + return name; } - @Override public String getDescription() { - return "Test Language Value Node"; + return description; } - }; + } private final ASTProber prober = new TestASTProber(); @@ -177,10 +174,10 @@ final TestLanguageNode testNode = (TestLanguageNode) node; if (node instanceof TestValueNode) { - instrumenter.probe(testNode).tagAs(VALUE_TAG, null); + instrumenter.probe(testNode).tagAs(InstrumentTestTag.VALUE_TAG, null); } else if (node instanceof TestAdditionNode) { - instrumenter.probe(testNode).tagAs(ADD_TAG, null); + instrumenter.probe(testNode).tagAs(InstrumentTestTag.ADD_TAG, null); } }