Remove old test

This commit is contained in:
Clément Fournier
2019-09-17 04:24:30 +02:00
parent 95d6ea3f37
commit 591cfc0a51
3 changed files with 3 additions and 52 deletions

View File

@ -115,6 +115,7 @@ public interface Node {
int getEndLine();
// FIXME should not be inclusive
int getEndColumn();
DataFlowNode getDataFlowNode();

View File

@ -44,7 +44,8 @@ public interface ScalaNode<T extends Tree> extends Node {
* Returns true if the node is implicit. If this node has no non-implicit
* descendant, then its text bounds identify an empty region of the source
* document. In that case, the {@linkplain #getEndColumn() end column} is
* smaller than the {@linkplain #getBeginColumn() begin column}.
* smaller than the {@linkplain #getBeginColumn() begin column}. That's
* because the end column is inclusive.
*/
// TODO this would be useful on the node interface for 7.0.0.
// we could filter them out from violations transparently

View File

@ -5,8 +5,6 @@
package net.sourceforge.pmd.lang.scala.ast;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
@ -17,59 +15,10 @@ import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersionHandler;
import net.sourceforge.pmd.lang.Parser;
import net.sourceforge.pmd.lang.scala.ScalaLanguageModule;
import net.sourceforge.pmd.lang.scala.ast.ScalaNode;
import net.sourceforge.pmd.lang.scala.ast.ScalaParserVisitorAdapter;
public class ScalaParserTest {
private static final String SCALA_TEST = "/parserFiles/helloworld.scala";
@Test
public void testLineNumbersAccuracy() throws Exception {
LanguageVersionHandler scalaVersionHandler = LanguageRegistry.getLanguage(ScalaLanguageModule.NAME)
.getDefaultVersion().getLanguageVersionHandler();
Parser parser = scalaVersionHandler.getParser(scalaVersionHandler.getDefaultParserOptions());
ScalaNode<?> root = (ScalaNode<?>) parser.parse(null,
new StringReader(IOUtils.toString(getClass().getResourceAsStream(SCALA_TEST), "UTF-8")));
final List<NodeLineMatcher> nodeLineTargets = new ArrayList<NodeLineMatcher>();
nodeLineTargets.add(new NodeLineMatcher("TermName", "Main", 1));
nodeLineTargets.add(new NodeLineMatcher("TypeName", "App", 1));
nodeLineTargets.add(new NodeLineMatcher("TermName", "println", 2));
ScalaParserVisitorAdapter<Void, Void> visitor = new ScalaParserVisitorAdapter<Void, Void>() {
public Void visit(ScalaNode<?> node, Void data) {
for (NodeLineMatcher nodeLine : nodeLineTargets) {
if (nodeLine.nodeName.equals(node.getXPathNodeName()) && nodeLine.nodeValue.equals(node.getImage())
&& nodeLine.lineNumber == node.getBeginLine()) {
nodeLine.matched = true;
}
}
return super.visit(node, data);
}
};
visitor.visit(root, null);
for (NodeLineMatcher nodeLine : nodeLineTargets) {
Assert.assertTrue("Did not successfully find the node " + nodeLine, nodeLine.matched);
}
}
class NodeLineMatcher {
String nodeName;
String nodeValue;
Integer lineNumber;
boolean matched = false;
NodeLineMatcher(String nodeName, String nodeValue, Integer lineNumber) {
this.nodeName = nodeName;
this.nodeValue = nodeValue;
this.lineNumber = lineNumber;
}
public String toString() {
return "NodeName: " + nodeName + " NodeValue: " + nodeValue + " Line Number: " + lineNumber;
}
}
@Test
public void testCountNodes() throws Exception {