forked from JavaTX/JavaCompilerCore
117 lines
3.4 KiB
Java
117 lines
3.4 KiB
Java
package strucTypes3;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
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.Field;
|
|
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
|
import de.dhbwstuttgart.syntaxtree.Method;
|
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
|
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
|
import de.dhbwstuttgart.syntaxtree.statement.Expression;
|
|
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
|
|
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
|
import de.dhbwstuttgart.syntaxtree.statement.MethodCall;
|
|
import de.dhbwstuttgart.syntaxtree.statement.Receiver;
|
|
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
|
import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
|
|
|
import org.junit.Test;
|
|
|
|
/**
|
|
* Dieser Test pr�ft nur, ob .java-Dateien fehlerfrei geparst werden. Der
|
|
* dabei erstellte Syntaxbaum wird nicht kontrolliert.
|
|
*
|
|
* @author janulrich
|
|
*
|
|
*/
|
|
public class GeneralParserTestConstruct {
|
|
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("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;
|
|
|
|
|
|
// Erstellen der Constrinats für die erste Klasse ---------------------------------------
|
|
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); });
|
|
|
|
|
|
// Erstellen der Interfaces für die erste Klasse
|
|
List<ClassOrInterface> sf2 = new ArrayList<>();
|
|
constraints.forEach( (constraint) -> {sf2.add( Construct.constructInterfaces(constraint)); } );
|
|
|
|
|
|
|
|
System.out.println(sf2.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception exc) {
|
|
exc.printStackTrace();
|
|
fail();
|
|
}
|
|
assertTrue("Tests durchlaufen", filenames.size() > 0);
|
|
}
|
|
}
|