58 lines
2.0 KiB
Java
58 lines
2.0 KiB
Java
|
package plugindevelopment.MartinTestCases;
|
|||
|
|
|||
|
import java.io.File;
|
|||
|
import java.io.IOException;
|
|||
|
import java.util.Vector;
|
|||
|
|
|||
|
import org.junit.Test;
|
|||
|
|
|||
|
import plugindevelopment.TypeInsertTester;
|
|||
|
import plugindevelopment.TypeInsertTests.MultipleTypesInsertTester;
|
|||
|
import junit.framework.TestCase;
|
|||
|
import mycompiler.MyCompiler;
|
|||
|
import mycompiler.MyCompilerAPI;
|
|||
|
import mycompiler.myparser.JavaParser.yyException;
|
|||
|
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
|||
|
import typinferenz.TypeInsertSet;
|
|||
|
|
|||
|
public class Tester extends TypeInsertTester{
|
|||
|
|
|||
|
public final static String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/MartinTestCases/";
|
|||
|
|
|||
|
public static void test(String sourceFileToInfere, Vector<String> mustContain){
|
|||
|
String gesamterSrc = "";
|
|||
|
String inferedSource = "";
|
|||
|
MyCompilerAPI compiler = MyCompiler.getAPI();
|
|||
|
try {
|
|||
|
compiler.parse(new File(rootDirectory + sourceFileToInfere));
|
|||
|
Vector<TypeinferenceResultSet> results = compiler.typeReconstruction();
|
|||
|
//TestCase.assertTrue("Es darf nicht mehr als eine L<>sungsm<73>glichkeit geben und nicht "+results.size(), results.size()==1);
|
|||
|
for(TypeinferenceResultSet result : results){
|
|||
|
Vector<TypeInsertSet> points = result.getTypeInsertionPoints();
|
|||
|
//TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
|
|||
|
for(TypeInsertSet point : points){
|
|||
|
//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(){
|
|||
|
Tester.test("OL.jav", new Vector<String>());
|
|||
|
}
|
|||
|
|
|||
|
}
|