View Javadoc
1 package test.net.sourceforge.pmd.symboltable; 2 3 import junit.framework.TestCase; 4 import net.sourceforge.pmd.ast.ASTCompilationUnit; 5 import net.sourceforge.pmd.ast.ASTIfStatement; 6 import net.sourceforge.pmd.ast.ASTTryStatement; 7 import net.sourceforge.pmd.symboltable.GlobalScope; 8 import net.sourceforge.pmd.symboltable.LocalScope; 9 import net.sourceforge.pmd.symboltable.ScopeCreator; 10 11 public class ScopeCreatorTest extends TestCase { 12 public void testScopesAreCreated() { 13 ScopeCreator sc = new ScopeCreator(); 14 15 ASTCompilationUnit acu = new ASTCompilationUnit(1); 16 acu.setScope(new GlobalScope()); 17 18 ASTTryStatement tryNode = new ASTTryStatement(2); 19 tryNode.setScope(new LocalScope()); 20 tryNode.jjtSetParent(acu); 21 22 ASTIfStatement ifNode = new ASTIfStatement(3); 23 ifNode.jjtSetParent(tryNode); 24 25 sc.visit(acu, null); 26 27 assertTrue(ifNode.getScope() instanceof LocalScope); 28 } 29 30 /* 31 public void testPush() { 32 SymbolTable s = new SymbolTable(); 33 s.push(new GlobalScope()); 34 assertEquals(1,s.depth()); 35 } 36 37 public void testPop() { 38 SymbolTable s = new SymbolTable(); 39 s.push(new GlobalScope()); 40 s.pop(); 41 assertEquals(0,s.depth()); 42 } 43 44 public void testPeek() { 45 SymbolTable s = new SymbolTable(); 46 Scope scope = new GlobalScope(); 47 s.push(scope); 48 assertEquals(scope, s.peek()); 49 } 50 51 public void testParentLinkage() { 52 SymbolTable s = new SymbolTable(); 53 Scope scope = new GlobalScope(); 54 s.push(scope); 55 Scope scope2 = new LocalScope(); 56 s.push(scope2); 57 Scope scope3 = new LocalScope(); 58 s.push(scope3); 59 assertEquals(scope2.getParent(), scope); 60 assertEquals(scope3.getParent(), scope2); 61 s.pop(); 62 assertEquals(scope2.getParent(), scope); 63 assertEquals(scope3.getParent(), scope2); 64 } 65 */ 66 }

This page was automatically generated by Maven