JavaTXCompilerInJavaTX/test/strucTypes5/ConstructTest.java

102 lines
3.4 KiB
Java

package strucTypes5;
import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.GenericContext;
import de.dhbwstuttgart.strucTypes5.algo.TI;
import de.dhbwstuttgart.strucTypes5.algo.Type;
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.typeVars.TypeVarStore;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typecheck.GenericTypeName;
import de.dhbwstuttgart.typecheck.JavaClassName;
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 ConstructTest {
private static final String rootDirectory = System.getProperty("user.dir") + "/test/strucTypes5/";
@Test
public void run() {
List<String> filenames = new ArrayList<String>();
filenames.add("ConstructTest.jav");
JavaTXParser parser = new JavaTXParser();
try {
for (String filename : filenames) {
System.out.println("Teste: " + filename);
SourceFile sf = parser.parse(new File(rootDirectory + filename));
/*
// 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());
List<AssumptionAbstract> assAll = new ArrayList<>();
assAll.addAll(assumptionMakerLocal.getResultAssumptionList());
assAll.addAll(makerGlobal.getAssumptionAbstractList());
AssumptionMap assumptionMap = new AssumptionMap();
assumptionMap.addAll(assAll);
*/
ClassOrInterface clA = sf.getClasses().get(0);
AssumptionMap map = new AssumptionMap();
TI ti = new TI(map , clA);
// Code der benötigt wird um ein Generic zu erstellen.
List<RefTypeOrTPHOrWildcardOrGeneric> list = new ArrayList<>();
GenericContext genericContext = new GenericContext(new JavaClassName("") , new String(""));
GenericTypeName genericTypeName = new GenericTypeName(genericContext,"nameOfGeneric");
GenericTypeVar genericTypeVar = new GenericTypeVar( genericTypeName, list , new NullToken() , new NullToken());
System.out.println(genericTypeVar);
//
}
} catch (Exception exc) {
exc.printStackTrace();
fail();
}
assertTrue("Tests durchlaufen", filenames.size() > 0);
}
}