Unify Test

This commit is contained in:
JanUlrich 2015-05-20 15:20:56 +02:00
parent fcac7fb04f
commit 19d0198d2a
3 changed files with 7128 additions and 0 deletions

View File

@ -0,0 +1,16 @@
class Test{
void methode(){
var;
var.methode();
var.methode();
}
}
class Klasse1 {
void methode(){
}
}
class Klasse2 {
void methode(){
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,54 @@
package unify;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import org.junit.Test;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.core.MyCompilerAPI;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.LoggerConfiguration;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.parser.JavaParser.yyException;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
public class UnifyFilter {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/unify/";
private final String testFile = "UnifyFilter.jav";
@Test
public void test(){
MyCompilerAPI compiler = MyCompiler.getAPI(new LoggerConfiguration().setOutput(Section.UNIFY, System.out));
try {
compiler.parse(new File(this.rootDirectory+testFile));
Menge<TypeinferenceResultSet> ergebnis = compiler.typeReconstruction();
//Nichts weiter unternehmen. Nur die Ausgabe des Unifikationsalgorithmus anzeigen.
String log = Logger.getWholeLog();
//System.out.println(log);
writeLogFile(log);
} catch (Exception e){
e.printStackTrace();
}
}
private void writeLogFile(String log){
try {
PrintWriter writer = new PrintWriter(rootDirectory+testFile+".log", "UTF-8");
writer.write(log);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}