JavaTXCompilerInJavaTX/test/typeinference/JavaTXCompilerTest.java

68 lines
2.8 KiB
Java
Raw Normal View History

2017-03-02 18:16:14 +01:00
package typeinference;
import de.dhbwstuttgart.core.JavaTXCompiler;
2017-07-05 17:42:41 +02:00
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
2017-06-30 11:13:15 +02:00
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
import de.dhbwstuttgart.typedeployment.TypeInsert;
2017-07-05 17:42:41 +02:00
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
2017-09-07 19:52:05 +02:00
import de.dhbwstuttgart.typeinference.result.ResultSet;
2017-03-02 18:16:14 +01:00
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;
2017-05-31 17:10:50 +02:00
import java.util.ArrayList;
import java.util.List;
2017-08-22 16:45:28 +02:00
import java.util.Set;
2017-03-02 18:16:14 +01:00
2017-06-28 21:10:28 +02:00
public class JavaTXCompilerTest extends JavaTXCompiler {
2017-03-02 18:16:14 +01:00
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
2017-05-31 17:10:50 +02:00
private static final List<File> filesToTest = new ArrayList<>();
2017-03-02 18:16:14 +01:00
@Test
public void test() throws IOException, java.lang.ClassNotFoundException {
2017-08-28 15:42:51 +02:00
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
2017-09-18 13:56:27 +02:00
//filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
//filesToTest.add(new File(rootDirectory+"test.jav"));
2017-08-28 15:42:51 +02:00
//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"));
2017-08-28 18:36:26 +02:00
//filesToTest.add(new File(rootDirectory+"Import.jav"));
//filesToTest.add(new File(rootDirectory+"BreakTest.jav"));
filesToTest.add(new File(rootDirectory+"WhileTest.jav"));
//filesToTest.add(new File(rootDirectory+"IfTest.jav"));
2017-05-31 17:10:50 +02:00
for(File f : filesToTest){
2017-07-05 17:50:38 +02:00
SourceFile sf = this.parse(f);
System.out.println(ASTPrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
System.out.println("-----------------------------------------------------------------------------------");
/*
2017-09-07 19:52:05 +02:00
for(ResultSet resultSet : this.typeInference()){
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
for(TypeInsert tip : result){
System.out.println(tip.insert(content));
}
2017-05-31 17:10:50 +02:00
}
*/
}
2017-05-31 17:10:50 +02:00
}
static String readFile(String path, Charset encoding)
throws IOException
{
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, encoding);
2017-03-02 18:16:14 +01:00
}
2017-06-30 11:13:15 +02:00
2017-03-02 18:16:14 +01:00
}