1 package test.net.sourceforge.pmd.symboltable;
2
3 import net.sourceforge.pmd.PMD;
4 import net.sourceforge.pmd.ast.ASTCompilationUnit;
5 import net.sourceforge.pmd.symboltable.ClassNameDeclaration;
6 import net.sourceforge.pmd.symboltable.Scope;
7
8 import java.util.Map;
9
10 public class GlobalScopeTest extends STBBaseTst {
11
12 public void testClassDeclAppears() {
13 parseCode(TEST1);
14 ASTCompilationUnit decl = (ASTCompilationUnit) (acu.findChildrenOfType(ASTCompilationUnit.class)).get(0);
15 Scope scope = decl.getScope();
16 Map m = scope.getClassDeclarations();
17 ClassNameDeclaration classNameDeclaration = (ClassNameDeclaration) m.keySet().iterator().next();
18 assertEquals(classNameDeclaration.getImage(), "Foo");
19 }
20
21 public void testEnums() {
22 parseCode15(TEST2);
23 }
24
25
26
27 private static final String TEST1 =
28 "public class Foo {}" + PMD.EOL;
29
30 private static final String TEST2 =
31 "public enum Bar {" + PMD.EOL +
32 " FOO1 { " + PMD.EOL +
33 " private static final String FIELD_NAME = \"\";" + PMD.EOL +
34 " }," + PMD.EOL +
35 " FOO2 { " + PMD.EOL +
36 " private static final String FIELD_NAME = \"\";" + PMD.EOL +
37 " }" + PMD.EOL +
38 "}" + PMD.EOL;
39
40
41 }