modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
modified: src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java
This commit is contained in:
parent
4ac67120a4
commit
29a7f2e7fb
@ -1,5 +1,6 @@
|
||||
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
|
||||
@ -8,6 +9,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FamilyOfGeneratedGenerics {
|
||||
public List<TPHConstraint> allConstraints = new ArrayList<>();
|
||||
public HashMap<String, PositionFinder.Position> posOfTPHs = new HashMap<>();
|
||||
public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) {
|
||||
this.allConstraints = tphExtractor.allCons;
|
||||
// this.posOfTPHs = tphExtractor.
|
||||
}
|
||||
|
||||
public static List<ClassConstraint> getClassConstraints(List<TPHConstraint> cs, HashMap<String, PositionFinder.Position> posOfTphs) { //Inputparameter List<TPHConstraint> constraintsSet weg
|
||||
List<ClassConstraint> cs_cl = new ArrayList<>();
|
||||
|
@ -91,7 +91,6 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
||||
inputConstraints.add(new TPHConstraint("A", "E", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("E", "D", TPHConstraint.Relation.EXTENDS));
|
||||
|
||||
|
||||
HashMap<String, PositionFinder.Position> tphPositions = new HashMap<>();
|
||||
tphPositions.put("A", PositionFinder.Position.FIELD);
|
||||
tphPositions.put("B", PositionFinder.Position.FIELD);
|
||||
@ -107,5 +106,52 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testTPHsAndGenerics() {
|
||||
/*
|
||||
class TPHsAndGenerics {
|
||||
Fun1<A,B> id = x -> x;
|
||||
C id2 (D x) {
|
||||
return id.apply(x);
|
||||
}
|
||||
E m(F a, G b){
|
||||
var c = m2(a,b);
|
||||
return a;
|
||||
}
|
||||
H m2(I a, J b){
|
||||
return b;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||
inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("B","C", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("D","A", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("F","E", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("F","I", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("G","J", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("J","H", TPHConstraint.Relation.EXTENDS));
|
||||
|
||||
HashMap<String, PositionFinder.Position> tphPositions = new HashMap<>();
|
||||
tphPositions.put("A", PositionFinder.Position.FIELD);
|
||||
tphPositions.put("B", PositionFinder.Position.FIELD);
|
||||
tphPositions.put("C", PositionFinder.Position.METHOD);
|
||||
tphPositions.put("D", PositionFinder.Position.METHOD);
|
||||
tphPositions.put("E", PositionFinder.Position.METHOD);
|
||||
tphPositions.put("F", PositionFinder.Position.METHOD);
|
||||
tphPositions.put("G", PositionFinder.Position.METHOD);
|
||||
tphPositions.put("H", PositionFinder.Position.METHOD);
|
||||
tphPositions.put("I", PositionFinder.Position.METHOD);
|
||||
tphPositions.put("J", PositionFinder.Position.METHOD);
|
||||
|
||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||
System.out.println(classConstraints);
|
||||
|
||||
assertFalse(classConstraints.isEmpty());
|
||||
assertTrue(classConstraints.size() == 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user