use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class StatementAndBraceFinderTest method testSimpleCaseStmtHasCorrectTypes.
@Test
public void testSimpleCaseStmtHasCorrectTypes() {
ASTExpression exp = getOrderedNodes(ASTExpression.class, TEST6).get(0);
DataFlowNode dfn = null;
dfn = exp.getDataFlowNode().getFlow().get(0);
assertTrue(dfn instanceof StartOrEndDataFlowNode);
dfn = exp.getDataFlowNode().getFlow().get(1);
assertEquals(2, dfn.getLine());
assertTrue(dfn.getNode() instanceof ASTProgramUnit);
dfn = exp.getDataFlowNode().getFlow().get(2);
assertEquals(4, dfn.getLine());
assertTrue(dfn.isType(NodeType.SWITCH_START));
assertTrue(dfn.isType(NodeType.CASE_LAST_STATEMENT));
dfn = exp.getDataFlowNode().getFlow().get(3);
assertEquals(5, dfn.getLine());
assertTrue(dfn.isType(NodeType.CASE_LAST_STATEMENT));
assertTrue(dfn.isType(NodeType.BREAK_STATEMENT));
dfn = exp.getDataFlowNode().getFlow().get(4);
assertEquals(6, dfn.getLine());
assertTrue(dfn.isType(NodeType.SWITCH_LAST_DEFAULT_STATEMENT));
assertTrue(dfn.isType(NodeType.BREAK_STATEMENT));
dfn = exp.getDataFlowNode().getFlow().get(5);
assertEquals(7, dfn.getLine());
assertTrue(dfn.isType(NodeType.SWITCH_END));
}
use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class StatementAndBraceFinderTest method testForStmtHasCorrectTypes.
@Test
public void testForStmtHasCorrectTypes() {
ASTExpression exp = getOrderedNodes(ASTExpression.class, TEST5).get(0);
DataFlowNode dfn = null;
dfn = exp.getDataFlowNode().getFlow().get(0);
assertTrue(dfn instanceof StartOrEndDataFlowNode);
dfn = exp.getDataFlowNode().getFlow().get(1);
assertTrue(dfn.getNode() instanceof ASTProgramUnit);
assertEquals(2, dfn.getLine());
dfn = exp.getDataFlowNode().getFlow().get(2);
assertEquals(3, dfn.getLine());
assertTrue(dfn.isType(NodeType.FOR_EXPR));
assertTrue(dfn.isType(NodeType.FOR_BEFORE_FIRST_STATEMENT));
dfn = exp.getDataFlowNode().getFlow().get(3);
assertEquals(3, dfn.getLine());
assertTrue(dfn.isType(NodeType.FOR_END));
}
use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class DataFlowNodeTest method testSetType.
@Test
public void testSetType() {
DataFlowNode node = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
node.setType(NodeType.BREAK_STATEMENT);
assertTrue(node.isType(NodeType.BREAK_STATEMENT));
assertFalse(node.isType(NodeType.CASE_LAST_STATEMENT));
}
use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class DataFlowNodeTest method testAddPathToChild.
@Test
public void testAddPathToChild() {
DataFlowNode parent = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
DataFlowNode child = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 12, false);
parent.addPathToChild(child);
assertEquals(parent.getChildren().size(), 1);
assertTrue(child.getParents().contains(parent));
assertTrue(parent.getChildren().contains(child));
}
use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class DataFlowNodeTest method testRemovePathToChild.
@Test
public void testRemovePathToChild() {
DataFlowNode parent = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
DataFlowNode child = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 12, false);
parent.addPathToChild(child);
assertTrue(parent.removePathToChild(child));
assertFalse(child.getParents().contains(parent));
assertFalse(parent.getChildren().contains(child));
}
Aggregations