Tests working again, word. Slowly understanding things...

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2967 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2004-09-30 17:47:34 +00:00
parent b7bf878e43
commit bee5663fd3
2 changed files with 15 additions and 20 deletions

View File

@ -16,14 +16,9 @@ public class AcceptanceTest extends ParserTst {
for (int i=0; i<methodNodes.size(); i++) {
ASTMethodDeclarator decl = (ASTMethodDeclarator)methodNodes.get(i);
IDataFlowNode inode = decl.getDataFlowNode();
/*
if (inode == null || inode.getFlow() == null) {
continue;
}
*/
for (int j = 0; j < inode.getChildren().size(); j++) {
IDataFlowNode child = (IDataFlowNode) inode.getChildren().get(j);
if (array[i][j] != child.getIndex()) {
if (array[i][j] != child.getIndex()-1) {
return false;
}
}
@ -32,9 +27,8 @@ public class AcceptanceTest extends ParserTst {
}
public void test_1() throws Throwable {
//assertTrue(check(TEST1_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST1)));
assertTrue(check(TEST1_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST1)));
}
/*
public void test_2() throws Throwable {
assertTrue(check(TEST2_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST2)));
}
@ -119,7 +113,6 @@ public class AcceptanceTest extends ParserTst {
public void test_30() throws Throwable {
assertTrue(check(TEST30_NODES, getOrderedNodes(ASTMethodDeclarator.class, TEST30)));
}
*/
/**
* first dimension: the index of a node

View File

@ -3,6 +3,7 @@ package test.net.sourceforge.pmd.dfa;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.ast.ASTCompilationUnit;
import net.sourceforge.pmd.ast.ASTMethodDeclaration;
import net.sourceforge.pmd.ast.ASTMethodDeclarator;
import net.sourceforge.pmd.dfa.DataFlowFacade;
import net.sourceforge.pmd.dfa.IDataFlowNode;
import net.sourceforge.pmd.symboltable.SymbolFacade;
@ -14,25 +15,26 @@ import java.util.Iterator;
public class GeneralFiddlingTest extends ParserTst {
public void test1() throws Throwable {
ASTMethodDeclaration meth = (ASTMethodDeclaration)(getOrderedNodes(ASTMethodDeclaration.class, TEST1).get(0));
ASTMethodDeclarator meth = (ASTMethodDeclarator)(getOrderedNodes(ASTMethodDeclarator.class, TEST1).get(0));
IDataFlowNode flow = meth.getDataFlowNode();
for (Iterator i = flow.getFlow().iterator(); i.hasNext();) {
System.out.println(i.next());
IDataFlowNode o = (IDataFlowNode)i.next();
System.out.println("Index:" + o.getIndex());
if (o.getChildren().size() > 1) {
System.out.println("Child 1 Index:" + ((IDataFlowNode)o.getChildren().get(1)).getIndex());
}
System.out.println(o);
System.out.println("================");
}
/*
ASTMethodDeclarator d = (ASTMethodDeclarator)nodes.get(0);
ASTMethodDeclaration p = (ASTMethodDeclaration)d.jjtGetParent();
System.out.println(p.getDataFlowNode());
*/
}
private static final String TEST1 =
"class Foo {" + PMD.EOL +
" void bar() {" + PMD.EOL +
" while (x == 0) {" + PMD.EOL +
" int y;" + PMD.EOL +
" int x = 0;" + PMD.EOL +
" if (x == 0) {" + PMD.EOL +
" x++;" + PMD.EOL +
" x = 0;" + PMD.EOL +
" }" + PMD.EOL +
" }" + PMD.EOL +
"}";