Search in sources :

Example 1 with ArrayTypes

use of net.sourceforge.pmd.typeresolution.testdata.ArrayTypes in project pmd by pmd.

the class ClassTypeResolverTest method testArrayTypes.

@Test
public void testArrayTypes() throws JaxenException {
    ASTCompilationUnit acu = parseAndTypeResolveForClass15(ArrayTypes.class);
    List<AbstractJavaTypeNode> expressions = convertList(acu.findChildNodesWithXPath("//VariableDeclarator"), AbstractJavaTypeNode.class);
    int index = 0;
    // int[] a = new int[1];
    testSubtreeNodeTypes(expressions.get(index++), int[].class);
    // Object[][] b = new Object[1][0];
    testSubtreeNodeTypes(expressions.get(index++), Object[][].class);
    // ArrayTypes[][][] c = new ArrayTypes[][][] { new ArrayTypes[1][2] };
    testSubtreeNodeTypes(expressions.get(index++), ArrayTypes[][][].class);
    // Make sure we got them all
    assertEquals("All expressions not tested", index, expressions.size());
}
Also used : ASTCompilationUnit(net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit) ArrayTypes(net.sourceforge.pmd.typeresolution.testdata.ArrayTypes) Constraint(net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint) AbstractJavaTypeNode(net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode) Test(org.junit.Test)

Aggregations

ASTCompilationUnit (net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit)1 AbstractJavaTypeNode (net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode)1 Constraint (net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint)1 ArrayTypes (net.sourceforge.pmd.typeresolution.testdata.ArrayTypes)1 Test (org.junit.Test)1