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

This page was automatically generated by Maven