package typeinference; import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.syntaxtree.SourceFile; 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.TypeInsertFactory; import de.dhbwstuttgart.typeinference.result.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 java.util.Set; public class JavaTXCompilerTest extends JavaTXCompiler { private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/"; private static final List filesToTest = new ArrayList<>(); @Test public void test() throws IOException, java.lang.ClassNotFoundException { //filesToTest.add(new File(rootDirectory+"Faculty.jav")); //filesToTest.add(new File(rootDirectory+"mathStruc.jav")); //filesToTest.add(new File(rootDirectory+"test.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")); //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")); filesToTest.add(new File(rootDirectory+"AssertTest.jav")); //filesToTest.add(new File(rootDirectory+"PrePostOperationTest.jav")); //filesToTest.add(new File(rootDirectory+"SwitchTest.jav")); //filesToTest.add(new File(rootDirectory+"WhileTest.jav")); for(File f : filesToTest){ SourceFile sf = this.parse(f); System.out.println("-------------------------------------|"+f.getName()+"|----------------------------------------------"); System.out.println(ASTPrinter.print(this.sourceFiles.get(sourceFiles.size()-1))); /* for(ResultSet resultSet : this.typeInference()){ Set result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet); 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); } }