2017-03-02 17:16:14 +00:00
|
|
|
package typeinference;
|
|
|
|
|
|
|
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
2017-05-05 14:20:12 +00:00
|
|
|
import de.dhbwstuttgart.parser.ClassNotFoundException;
|
2017-05-18 11:17:52 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
2017-06-30 09:13:15 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
2017-06-28 19:10:28 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
2017-06-30 09:13:15 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
|
2017-06-14 02:07:27 +00:00
|
|
|
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
2017-05-18 11:17:52 +00:00
|
|
|
import de.dhbwstuttgart.typedeployment.TypeInsertPoint;
|
|
|
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
2017-03-02 17:16:14 +00:00
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2017-05-18 11:17:52 +00:00
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Paths;
|
2017-05-31 15:10:50 +00:00
|
|
|
import java.util.ArrayList;
|
2017-05-18 11:17:52 +00:00
|
|
|
import java.util.List;
|
2017-03-02 17:16:14 +00:00
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
2017-06-28 19:10:28 +00:00
|
|
|
public class JavaTXCompilerTest extends JavaTXCompiler {
|
2017-03-02 17:16:14 +00:00
|
|
|
|
|
|
|
private static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
|
2017-05-31 15:10:50 +00:00
|
|
|
private static final List<File> filesToTest = new ArrayList<>();
|
2017-03-02 17:16:14 +00:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void test() throws IOException, ClassNotFoundException {
|
2017-09-04 07:26:02 +00:00
|
|
|
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
|
|
|
filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
|
|
|
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
2017-06-26 16:19:56 +00:00
|
|
|
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
|
2017-06-12 16:57:12 +00:00
|
|
|
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
|
|
|
|
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
|
2017-05-31 15:10:50 +00:00
|
|
|
//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){
|
2017-06-28 19:10:28 +00:00
|
|
|
this.parse(f);
|
2017-06-30 09:13:15 +00:00
|
|
|
System.out.println(ASTTypePrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
2017-06-28 19:10:28 +00:00
|
|
|
List<TypeInsert> result = this.getTypeInserts(f);
|
2017-05-31 15:10:50 +00:00
|
|
|
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
2017-06-14 02:07:27 +00:00
|
|
|
for(TypeInsert tip : result){
|
2017-05-31 15:10:50 +00:00
|
|
|
System.out.println(tip.insert(content));
|
|
|
|
}
|
2017-05-18 11:17:52 +00:00
|
|
|
}
|
2017-05-31 15:10:50 +00:00
|
|
|
|
2017-05-18 11:17:52 +00: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 17:16:14 +00:00
|
|
|
}
|
2017-06-30 09:13:15 +00:00
|
|
|
|
2017-06-30 11:09:59 +00:00
|
|
|
}
|