new file: src/test/java/insertGenerics/TestLocalVarLambda.java
This commit is contained in:
parent
55e44d62de
commit
6e0e575524
54
src/test/java/insertGenerics/TestLocalVarLambda.java
Normal file
54
src/test/java/insertGenerics/TestLocalVarLambda.java
Normal file
@ -0,0 +1,54 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
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.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.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestLocalVarLambda {
|
||||
|
||||
private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/";
|
||||
private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||
private static ClassLoader loader;
|
||||
private static Class<?> classToTest;
|
||||
private static Object instanceOfClass;
|
||||
private static String className = "TestLocalVarLambda";
|
||||
|
||||
@Test
|
||||
public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||
execute(new File(rootDirectory+className+".jav"));
|
||||
}
|
||||
|
||||
private static class TestResultSet{
|
||||
|
||||
}
|
||||
|
||||
public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass(className);
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
return new TestResultSet();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user