01: package test.net.sourceforge.pmd.ast;
02:
03: import static org.junit.Assert.assertTrue;
04: import net.sourceforge.pmd.PMD;
05: import net.sourceforge.pmd.ast.ASTPrimarySuffix;
06:
07: import org.junit.Test;
08:
09: import test.net.sourceforge.pmd.testframework.ParserTst;
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()))
19: .isArrayDereference());
20: }
21:
22: @Test
23: public void testArguments() throws Throwable {
24: Set ops = getNodes(ASTPrimarySuffix.class, TEST2);
25: assertTrue(((ASTPrimarySuffix) (ops.iterator().next()))
26: .isArguments());
27: }
28:
29: private static final String TEST1 = "public class Foo {" + PMD.EOL
30: + " {x[0] = 2;}" + PMD.EOL + "}";
31:
32: private static final String TEST2 = "public class Foo {" + PMD.EOL
33: + " {foo(a);}" + PMD.EOL + "}";
34:
35: public static junit.framework.Test suite() {
36: return new junit.framework.JUnit4TestAdapter(
37: ASTPrimarySuffixTest.class);
38: }
39: }
|