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