forked from JavaTX/JavaCompilerCore
66bbf9d52d
neue Datei: ../../git_pull_origin_bigRefactoring geändert: ../../test/typeinference/JavaTXCompilerTest.java
63 lines
2.4 KiB
Java
63 lines
2.4 KiB
Java
package typeinference;
|
|
|
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
|
import de.dhbwstuttgart.parser.ClassNotFoundException;
|
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
|
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
|
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
|
|
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
|
import de.dhbwstuttgart.typedeployment.TypeInsertPoint;
|
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
|
import org.junit.Test;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.nio.charset.Charset;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Paths;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
public class JavaTXCompilerTest extends JavaTXCompiler {
|
|
|
|
private static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
|
|
private static final List<File> filesToTest = new ArrayList<>();
|
|
|
|
@Test
|
|
public void test() throws IOException, ClassNotFoundException {
|
|
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
|
filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"Vector.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"Generics.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"MethodsEasy.jav"));
|
|
//filesToTest.add(new File(rootDirectory+"Matrix.jav"));
|
|
for(File f : filesToTest){
|
|
this.parse(f);
|
|
System.out.println(ASTTypePrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
|
List<TypeInsert> result = this.getTypeInserts(f);
|
|
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
|
for(TypeInsert tip : result){
|
|
System.out.println(tip.insert(content));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
static String readFile(String path, Charset encoding)
|
|
throws IOException
|
|
{
|
|
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
|
return new String(encoded, encoding);
|
|
}
|
|
|
|
}
|