JavaTXCompilerInJavaTX/test/strucTypes5/Class2StringTest.java

96 lines
3.3 KiB
Java

package strucTypes5;
import com.sun.org.apache.xpath.internal.SourceTree;
import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.strucTypes5.algo.TypeExpr;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionAbstract;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMakerGlobal;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMakerLocal;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMap;
import de.dhbwstuttgart.strucTypes5.ausgabe.Class2String;
import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* Dieser Test pr�ft nur, ob .java-Dateien fehlerfrei geparst werden. Der
* dabei erstellte Syntaxbaum wird nicht kontrolliert.
*
* @author janulrich
*
*/
public class Class2StringTest {
private static final String rootDirectory = System.getProperty("user.dir") + "/test/strucTypes5/";
@Test
public void run() {
List<String> filenames = new ArrayList<String>();
filenames.add("AssumptionTest.jav");
JavaTXParser parser = new JavaTXParser();
try {
for (String filename : filenames) {
System.out.println("Teste: " + filename);
SourceFile sf = parser.parse(new File(rootDirectory + filename));
ClassOrInterface classA = sf.getClasses().get(0);
// Test of the Global Assumption Maker who make mass und fass;
TypeVarStore typeVarStore = new TypeVarStore();
AssumptionMakerGlobal makerGlobal = new AssumptionMakerGlobal(sf.getClasses().get(0), typeVarStore );
//System.out.println(typeVarStore.toString());
//System.out.println(makerGlobal.getAssumptionAbstractList().toString()) ;
// Test of the Local AssumptionMaker who only makes the Assumption for an Local Method;
AssumptionMakerLocal assumptionMakerLocal = new AssumptionMakerLocal(sf.getClasses().get(0).getMethods().get(0) , typeVarStore);
//System.out.println(assumptionMakerLocal.getResultAssumptionList());
System.out.println(typeVarStore.toString());
// Teste Blank
Class2String class2String1 = new Class2String();
System.out.println("Blank");
System.out.println(class2String1.generateStringBlank(classA));
//Teste TPH
Class2String class2String2 = new Class2String();
System.out.println("TPH");
System.out.println(class2String2.generateStringTPH(classA));
ArrayList<AssumptionAbstract> assAll = new ArrayList<>();
assAll.addAll(assumptionMakerLocal.getResultAssumptionList());
assAll.addAll(makerGlobal.getAssumptionAbstractList());
AssumptionMap assumptionMap = new AssumptionMap();
assumptionMap.addAll(assAll);
TypeExpr typeExpr = new TypeExpr(assumptionMap , sf.getClasses().get(0).getMethods().get(0) , typeVarStore );
// Teste TypeVars Problem Typevars werden benötigt
Class2String class2String3 = new Class2String();
System.out.println("TypeVars");
System.out.println(class2String3.generateStringTypeVars(classA ,typeVarStore ));
}
} catch (Exception exc) {
exc.printStackTrace();
fail();
}
assertTrue("Tests durchlaufen", filenames.size() > 0);
}
}