JavaTXCompilerInJavaTX/test/strucTypes5/ConvertTest.java
2017-05-11 14:32:19 +02:00

97 lines
2.6 KiB
Java

package strucTypes5;
import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.strucTypes4.syntaxtree.Class;
import de.dhbwstuttgart.strucTypes5.algo.TI;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMap;
import de.dhbwstuttgart.strucTypes5.constraints.*;
import de.dhbwstuttgart.strucTypes5.solve.Ruler;
import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarFactory;
import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarInterface;
import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarRefType;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
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 ConvertTest {
private static final String rootDirectory = System.getProperty("user.dir") + "/test/strucTypes5/";
@Test
public void run() {
List<String> filenames = new ArrayList<String>();
filenames.add("ConvertTest.jav");
JavaTXParser parser = new JavaTXParser();
try {
for (String filename : filenames) {
System.out.println("Teste: " + filename);
SourceFile sf = parser.parse(new File(rootDirectory + filename));
SourceFile sfdebug = sf;
ClassOrInterface mainClass = sf.getClasses().get(0);
ClassOrInterface aClass = sf.getClasses().get(1);
//Set<ClassOrInterface> typeinfo = new HashSet<>();
//ConstraintSet<Constraint> constraints = sf.getClasses().get(0).getConstraints(new TypeInferenceInformation(typeinfo));
//ConstraintSet cs = constraints;
AssumptionMap assumptionMap = new AssumptionMap();
TI ti = new TI(assumptionMap, aClass);
//TI ti1 = new TI(ti.assresult, mainClass);
System.out.println(ti.resultConstraints);
//Converter
ConstraintSet<Constraint> constraintSet = ConvertConstraints.convert(ti.resultConstraints);
// Construc Interface from Templates
System.out.println(constraintSet.toString());
}
} catch (Exception exc) {
exc.printStackTrace();
fail();
}
assertTrue("Tests durchlaufen", filenames.size() > 0);
}
}