modified: src/test/java/insertGenerics/TestAny.java
modified: src/test/java/insertGenerics/TestGGFinder.java modified: src/test/java/insertGenerics/TestLocalVarLambda.java modified: src/test/java/insertGenerics/TestTPHsAndGenerics.java modified: src/test/java/insertGenerics/TestTwoArgs.java modified: src/test/java/insertGenerics/TestTwoArgs2.java Tests fuer GeneratedGenerics eingefuegt
This commit is contained in:
parent
8c6027645f
commit
e5816bac22
@ -1,6 +1,10 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -10,12 +14,16 @@ import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
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.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -40,6 +48,28 @@ public class TestAny {
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
|
||||
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
|
||||
classConstraintsTest.add(new ClassConstraint("N", "O", Relation.EXTENDS));
|
||||
classConstraintsTest.add(new ClassConstraint("N", "U", Relation.EXTENDS));
|
||||
classConstraintsTest.add(new ClassConstraint("U", "O", Relation.EXTENDS));
|
||||
classConstraintsTest.add(new ClassConstraint("O", "java/lang/Object", Relation.EXTENDS));
|
||||
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
|
||||
List<MethodConstraint> lmc;
|
||||
lmc = new ArrayList<>();
|
||||
lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH RanyMethod()", lmc);
|
||||
lmc = new ArrayList<>();
|
||||
methodConstraintsWithPositionTest.put("TPH UotherMethod(TPH U)", lmc);
|
||||
|
||||
FamilyOfGeneratedGenerics fogg = compiler.fogg;
|
||||
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
|
||||
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
|
||||
|
||||
assertEquals(expectedClassCons, computedClassCons);
|
||||
|
||||
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
|
||||
|
||||
//compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles);
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
|
@ -1,6 +1,10 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -10,6 +14,8 @@ import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -19,6 +25,8 @@ 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.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -45,6 +53,33 @@ public class TestGGFinder {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
|
||||
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
|
||||
classConstraintsTest.add(new ClassConstraint("S", "java/lang/Object", Relation.EXTENDS));
|
||||
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
|
||||
List<MethodConstraint> lmc;
|
||||
lmc = new ArrayList<>();
|
||||
lmc.add(new MethodConstraint("P", "AC", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AC", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH ACid(TPH P)", lmc);
|
||||
lmc = new ArrayList<>();
|
||||
lmc.add(new MethodConstraint("T", "S", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH SsetA(TPH T)", lmc);
|
||||
lmc = new ArrayList<>();
|
||||
lmc.add(new MethodConstraint("AC", "Y", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("Z", "P", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("P", "AC", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("Y", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("voidm(TPH YTPH Z)", lmc);
|
||||
|
||||
FamilyOfGeneratedGenerics fogg = compiler.fogg;
|
||||
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
|
||||
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
|
||||
|
||||
assertEquals(expectedClassCons, computedClassCons);
|
||||
|
||||
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
|
||||
|
||||
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass(className);
|
||||
|
@ -77,9 +77,9 @@ public class TestLocalVarLambda {
|
||||
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
|
||||
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
|
||||
|
||||
assertEquals(computedClassCons, expectedClassCons);
|
||||
assertEquals(expectedClassCons, computedClassCons);
|
||||
|
||||
assertEquals(fogg.methodConstraintsWithPosition, methodConstraintsWithPositionTest);
|
||||
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
|
||||
|
||||
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
|
@ -79,9 +79,9 @@ public class TestTPHsAndGenerics {
|
||||
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
|
||||
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
|
||||
|
||||
assertEquals(computedClassCons, expectedClassCons);
|
||||
assertEquals(expectedClassCons, computedClassCons);
|
||||
|
||||
assertEquals(fogg.methodConstraintsWithPosition, methodConstraintsWithPositionTest);
|
||||
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
|
||||
|
||||
/*
|
||||
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
|
||||
|
@ -84,9 +84,9 @@ public class TestTwoArgs {
|
||||
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
|
||||
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
|
||||
|
||||
assertEquals(computedClassCons, expectedClassCons);
|
||||
assertEquals(expectedClassCons, computedClassCons);
|
||||
|
||||
assertEquals(fogg.methodConstraintsWithPosition, methodConstraintsWithPositionTest);
|
||||
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
|
||||
|
||||
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
|
@ -1,6 +1,10 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -10,6 +14,8 @@ import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -19,6 +25,8 @@ 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.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -45,6 +53,39 @@ public class TestTwoArgs2 {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
|
||||
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
|
||||
classConstraintsTest.add(new ClassConstraint("N", "java/lang/Object", Relation.EXTENDS));
|
||||
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
|
||||
List<MethodConstraint> lmc;
|
||||
lmc = new ArrayList<>();
|
||||
lmc.add(new MethodConstraint("AG", "AA", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("U", "P", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AA", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH AAm(TPH AATPH U)", lmc);
|
||||
lmc = new ArrayList<>();
|
||||
lmc.add(new MethodConstraint("AB", "P", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AC", "U", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AB", "AA", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AA", "U", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AG", "AA", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("U", "AA", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH AAmain(TPH ABTPH AC)", lmc);
|
||||
lmc = new ArrayList<>();
|
||||
lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AG", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH AGid(TPH P)", lmc);
|
||||
|
||||
FamilyOfGeneratedGenerics fogg = compiler.fogg;
|
||||
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
|
||||
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
|
||||
|
||||
assertEquals(expectedClassCons, computedClassCons);
|
||||
|
||||
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
|
||||
|
||||
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass(className);
|
||||
|
Loading…
Reference in New Issue
Block a user