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;
|
2017-09-22 18:19:34 +02:00
|
|
|
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
2017-06-30 11:13:15 +02:00
|
|
|
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
2017-09-22 18:19:34 +02:00
|
|
|
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
|
2017-06-14 04:07:27 +02:00
|
|
|
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;
|
2017-05-18 13:17:52 +02:00
|
|
|
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;
|
2017-05-18 13:17:52 +02:00
|
|
|
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
|
|
|
|
2017-09-20 17:36:16 +02: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
|
2017-07-14 17:47:02 +02:00
|
|
|
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"));
|
2017-09-20 17:36:16 +02:00
|
|
|
//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"));
|
2017-09-25 08:17:36 +02:00
|
|
|
|
|
|
|
filesToTest.add(new File(rootDirectory+"BreakTest.jav"));
|
|
|
|
filesToTest.add(new File(rootDirectory+"WhileTest.jav"));
|
|
|
|
filesToTest.add(new File(rootDirectory+"IfTest.jav"));
|
|
|
|
filesToTest.add(new File(rootDirectory+"AssertTest.jav"));
|
|
|
|
//filesToTest.add(new File(rootDirectory+"PrePostOperationTest.jav"));
|
|
|
|
//filesToTest.add(new File(rootDirectory+"SwitchTest.jav"));
|
2017-09-20 17:36:16 +02:00
|
|
|
filesToTest.add(new File(rootDirectory+"WhileTest.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);
|
2017-09-25 08:17:36 +02:00
|
|
|
System.out.println("-------------------------------------|"+f.getName()+"|----------------------------------------------");
|
2017-09-22 18:19:34 +02:00
|
|
|
System.out.println(ASTPrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
2017-09-25 08:17:36 +02:00
|
|
|
|
2017-09-20 17:36:16 +02:00
|
|
|
/*
|
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-09-20 17:36:16 +02:00
|
|
|
*/
|
2017-05-18 13:17:52 +02:00
|
|
|
}
|
2017-05-31 17:10:50 +02:00
|
|
|
|
2017-05-18 13:17:52 +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
|
|
|
}
|