package quicktests;

import junit.framework.TestCase;
import testframework.TestCaseParse;
import AST.*;

public class TestAnalysis extends TestCaseParse {
	String[] filesToParse = {"quicktests/A.java", "quicktests/B.java", "quicktests/C.java"};
   	String classpath = "testprograms";
  public void testCallGraph() {
  	  Program program = parse(classpath, filesToParse);
      assertEquals(7, program.countTCGedgesInSourcefiles());
      assertEquals(0, program.countTCGedgesInImportedfiles()); // Methods of class files are not analyzed.
   }
   public void testDevirtualization() {
 	  Program program = parse(classpath, filesToParse);
	  assertEquals(8, program.totalVirtualCountInSourceFiles());
 	  assertEquals(5, program.ZSdevirtCountInSourceFiles());
 	  assertEquals(7, program.NOMdevirtCountInSourceFiles());
   }
   public void testCallers() {
	  Program program = parse(classpath, filesToParse);
      assertEquals(7, program.countCallerEdgesInSourcefiles());
      assertEquals(0, program.countCallerEdgesInImportedfiles());  // Methods of class files are not analyzed.
   }
   
   public void testReachable() {
	  Program program = parse(classpath, filesToParse);
	  assertEquals(5, program.countReachableMethodsInSourcefiles());
  }

   public static void main(String[] args) {
     junit.swingui.TestRunner.run(TestAnalysis.class);
   }

}
