JavaTXCompilerInJavaTX/test/strucTypes3/GeneralParserTestNeuX.java
2017-04-20 23:17:43 +02:00

88 lines
2.5 KiB
Java

package strucTypes3;
import de.dhbwstuttgart.parser.JavaTXParser;
import de.dhbwstuttgart.strucTypes3.AssTuple;
import de.dhbwstuttgart.strucTypes3.AssumptionGenerator;
import de.dhbwstuttgart.strucTypes3.ConstraintAbstract;
import de.dhbwstuttgart.strucTypes3.HelpMethoden;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.statement.Expression;
import de.dhbwstuttgart.syntaxtree.statement.Return;
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 GeneralParserTestNeuX {
private static final String rootDirectory = System.getProperty("user.dir") + "/test/strucTypes3/";
@Test
public void run() {
/*
* Auflistung aller Files die getestet werden sollen
*/
List<String> filenames = new ArrayList<String>();
// filenames.add("FieldInitializationTest.jav");
// filenames.add("ImportTest.jav");
// filenames.add("StatementsTest.jav");
// filenames.add("ImportTestGeneric.jav");
// filenames.add("BoundedParameter.jav");
// filenames.add("GenericFieldVarTest.jav");
// filenames.add("FieldVarTest.jav");
//filenames.add("Main.jav");
filenames.add("StructuralTypesSimpleSkript.jav");
// filenames.add("StructuralTypesField.jav");
// filenames.add("Main.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 aktClass = sf.getClasses().get(0);
AssTuple ass = AssumptionGenerator.generateAssumptions(aktClass);
List<ConstraintAbstract> constraints = new ArrayList<>();
for (Method m : aktClass.getMethods()) {
Return rt = (Return) m.get_Block().statements.get(0);
Expression ex = (Expression) rt.get_Expression();
constraints.addAll(HelpMethoden.TypeExpr(ass, ex, m, aktClass));
}
constraints.forEach( (x) -> {System.out.println(x); });
*/
}
} catch (Exception exc) {
exc.printStackTrace();
fail();
}
assertTrue("Tests durchlaufen", filenames.size() > 0);
}
}