102 lines
3.7 KiB
Java
102 lines
3.7 KiB
Java
package plugindevelopment.MartinTestCases;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
|
import de.dhbwstuttgart.typeinference.Menge;
|
|
|
|
import org.junit.Test;
|
|
|
|
import de.dhbwstuttgart.core.MyCompiler;
|
|
import de.dhbwstuttgart.core.MyCompilerAPI;
|
|
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
|
import de.dhbwstuttgart.logger.Section;
|
|
import de.dhbwstuttgart.parser.JavaParser.yyException;
|
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
|
import plugindevelopment.TypeInsertTester;
|
|
import plugindevelopment.TypeInsertTests.MultipleTypesInsertTester;
|
|
import junit.framework.TestCase;
|
|
|
|
public class Tester extends TypeInsertTester{
|
|
|
|
public final static String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/MartinTestCases/";
|
|
|
|
public static void test(String sourceFileToInfere, Menge<String> mustContain){
|
|
String gesamterSrc = "";
|
|
String inferedSource = "";
|
|
MyCompilerAPI compiler = MyCompiler.getAPI(new LoggerConfiguration().setOutput(Section.TYPEINFERENCE, System.out));
|
|
try {
|
|
SourceFile parsed = compiler.parse(new File(rootDirectory + sourceFileToInfere));
|
|
Menge<SourceFile> sourceFiles = new Menge<>();
|
|
sourceFiles.add(parsed);
|
|
Menge<TypeinferenceResultSet> results = compiler.typeReconstruction(sourceFiles);
|
|
//TestCase.assertTrue("Es darf nicht mehr als eine L�sungsm�glichkeit geben und nicht "+results.size(), results.size()==1);
|
|
for(TypeinferenceResultSet result : results){
|
|
TypeInsertSet point = result.getTypeInsertionPoints();
|
|
//TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
|
|
|
|
//TestCase.assertTrue("Es muss mindestens ein TypeInsertPoint vorhanden sein", point.points.size()>0);
|
|
if(point.points.size()>0){
|
|
inferedSource = point.insertAllTypes(TypeInsertTester.getFileContent(rootDirectory + sourceFileToInfere));
|
|
System.out.println(inferedSource);
|
|
gesamterSrc += inferedSource;
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException | yyException e) {
|
|
e.printStackTrace();
|
|
TestCase.fail();
|
|
}
|
|
for(String containString : mustContain){
|
|
TestCase.assertTrue("\""+containString+"\" muss in den inferierten L�sungen vorkommen",gesamterSrc.contains(containString));
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void runTests(){
|
|
Menge<String> testFiles = new Menge<String>();
|
|
//testFiles.add("OL3.jav");
|
|
testFiles.add("Plus1_Float_Double.jav");
|
|
///*
|
|
testFiles.add("AchimTest1.jav");
|
|
//testFiles.add("MatrixWhile.jav");
|
|
//testFiles.add("BoundedType1.jav");
|
|
testFiles.add("BoundedType2.jav");
|
|
testFiles.add("BoundedType.jav");
|
|
|
|
testFiles.add("OL2.jav");
|
|
testFiles.add("OL.jav");
|
|
testFiles.add("Simple.jav");
|
|
testFiles.add("SMatrix.jav");
|
|
testFiles.add("UnifyTest1.jav");
|
|
testFiles.add("UsecaseEight_pl.jav");
|
|
testFiles.add("UsecaseFive_pl.jav");
|
|
testFiles.add("UsecaseFour_pl.jav");
|
|
testFiles.add("Usecase_MUBTest1.jav");
|
|
testFiles.add("Usecase_MUBTest2.jav");
|
|
testFiles.add("Usecase_MUBTest3.jav");
|
|
testFiles.add("Usecase_MUBTest4.jav");
|
|
testFiles.add("Usecase_MUBTest5.jav");
|
|
testFiles.add("Usecase_MUBTest6.jav");
|
|
testFiles.add("Usecase_MUBTest.jav");
|
|
testFiles.add("UsecaseNine_pl.jav");
|
|
testFiles.add("UsecaseOne_pl.jav");
|
|
testFiles.add("UsecaseSeven_pl.jav");
|
|
testFiles.add("UsecaseSix_pl.jav");
|
|
testFiles.add("UsecaseTen_pl.jav");
|
|
testFiles.add("UsecaseThree_pl.jav");
|
|
testFiles.add("UsecaseThree_pl.orig.jav");
|
|
testFiles.add("UsecaseTwo_pl.jav");
|
|
testFiles.add("ZweiKlassen.jav");
|
|
//*/
|
|
for(String file : testFiles){
|
|
System.out.println("Testfile: "+file);
|
|
Tester.test(file, new Menge<String>());
|
|
}
|
|
}
|
|
|
|
}
|