View Javadoc

    1   package net.sourceforge.pmd.ast;
    2
    3   import static org.junit.Assert.assertTrue;
    4   import net.sourceforge.pmd.PMD;
    5   import net.sourceforge.pmd.lang.java.ast.ASTPrimarySuffix;
    6   import net.sourceforge.pmd.testframework.ParserTst;
    7
    8   import org.junit.Test;
    9
    10
    11  import java.util.Set;
    12
    13  public class ASTPrimarySuffixTest extends ParserTst {
    14
    15      @Test
    16      public void testArrayDereference() throws Throwable {
    17          Set ops = getNodes(ASTPrimarySuffix.class, TEST1);
    18          assertTrue(((ASTPrimarySuffix) (ops.iterator().next())).isArrayDereference());
    19      }
    20
    21      @Test
    22      public void testArguments() throws Throwable {
    23          Set ops = getNodes(ASTPrimarySuffix.class, TEST2);
    24          assertTrue(((ASTPrimarySuffix) (ops.iterator().next())).isArguments());
    25      }
    26
    27      private static final String TEST1 =
    28              "public class Foo {" + PMD.EOL +
    29              "  {x[0] = 2;}" + PMD.EOL +
    30              "}";
    31
    32      private static final String TEST2 =
    33              "public class Foo {" + PMD.EOL +
    34              "  {foo(a);}" + PMD.EOL +
    35              "}";
    36
    37      public static junit.framework.Test suite() {
    38          return new junit.framework.JUnit4TestAdapter(ASTPrimarySuffixTest.class);
    39      }
    40  }