1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package test.net.sourceforge.pmd.symboltable;
5
6 import junit.framework.TestCase;
7 import net.sourceforge.pmd.PMD;
8 import net.sourceforge.pmd.ast.ASTCompilationUnit;
9 import net.sourceforge.pmd.ast.ASTInitializer;
10 import net.sourceforge.pmd.ast.JavaParser;
11 import net.sourceforge.pmd.symboltable.SymbolFacade;
12
13 import java.io.StringReader;
14
15 public class AcceptanceTest extends TestCase {
16
17 public void testClashingSymbols() {
18 JavaParser parser = new JavaParser(new StringReader(TEST1));
19 ASTCompilationUnit c = parser.CompilationUnit();
20 SymbolFacade stb = new SymbolFacade();
21 stb.initializeWith(c);
22 }
23
24 public void testInitializer() {
25 JavaParser parser = new JavaParser(new StringReader(TEST2));
26 ASTCompilationUnit c = parser.CompilationUnit();
27 ASTInitializer a = (ASTInitializer)(c.findChildrenOfType(ASTInitializer.class)).get(0);
28 assertFalse(a.isStatic());
29 }
30
31 public void testStaticInitializer() {
32 JavaParser parser = new JavaParser(new StringReader(TEST3));
33 ASTCompilationUnit c = parser.CompilationUnit();
34 ASTInitializer a = (ASTInitializer)(c.findChildrenOfType(ASTInitializer.class)).get(0);
35 assertTrue(a.isStatic());
36 }
37
38 private static final String TEST1 =
39 "import java.io.*;" + PMD.EOL +
40 "public class Foo {" + PMD.EOL +
41 " void buz( ) {" + PMD.EOL +
42 " Object o = new Serializable() { int x; };" + PMD.EOL +
43 " Object o1 = new Serializable() { int x; };" + PMD.EOL +
44 " }" + PMD.EOL +
45 "}" + PMD.EOL;
46
47 private static final String TEST2 =
48 "public class Foo {" + PMD.EOL +
49 " {} " + PMD.EOL +
50 "}" + PMD.EOL;
51
52 private static final String TEST3 =
53 "public class Foo {" + PMD.EOL +
54 " static {} " + PMD.EOL +
55 "}" + PMD.EOL;
56
57 }
This page was automatically generated by Maven