51 lines
1.6 KiB
Java
51 lines
1.6 KiB
Java
package plugindevelopment;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.Vector;
|
|
|
|
import junit.framework.TestCase;
|
|
import mycompiler.MyCompiler;
|
|
import mycompiler.MyCompilerAPI;
|
|
import mycompiler.myparser.JavaParser.yyException;
|
|
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
|
|
|
import org.junit.Test;
|
|
|
|
import typinferenz.TypeInsertSet;
|
|
|
|
public class OverloadingInsertTest {
|
|
private static final String TEST_FILE = "OverloadingInsertTest.jav";
|
|
|
|
@Test
|
|
public void run(){
|
|
this.test(this.TEST_FILE);
|
|
}
|
|
|
|
public static void test(String sourceFileToInfere){
|
|
String inferedSource = "";
|
|
MyCompilerAPI compiler = MyCompiler.getAPI();
|
|
try {
|
|
compiler.parse(new File(TypeInsertTester.rootDirectory + sourceFileToInfere));
|
|
Vector<TypeinferenceResultSet> results = compiler.typeReconstruction();
|
|
//TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmö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(TypeInsertTester.rootDirectory + sourceFileToInfere));
|
|
System.out.println(inferedSource);
|
|
}
|
|
}
|
|
}
|
|
|
|
} catch (IOException | yyException e) {
|
|
e.printStackTrace();
|
|
TestCase.fail();
|
|
}
|
|
}
|
|
|
|
}
|