modified: src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java
This commit is contained in:
parent
d06c6abb5a
commit
c2f0368d2e
@ -3,7 +3,6 @@ package insertGenerics;
|
|||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.insertGenerics.*;
|
import de.dhbwstuttgart.bytecode.insertGenerics.*;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -12,31 +11,27 @@ import java.util.List;
|
|||||||
|
|
||||||
public class FamilyOfGeneratedGenericsTest extends TestCase {
|
public class FamilyOfGeneratedGenericsTest extends TestCase {
|
||||||
|
|
||||||
/*
|
|
||||||
public void testIdentityMethod(){
|
public void testIdentityMethod(){
|
||||||
*/
|
/*
|
||||||
/*
|
|
||||||
Example method:
|
Example method:
|
||||||
A id(B i) return i;
|
A id(B i) return i;
|
||||||
gives constraint: B <. A, which is a method constraint
|
gives constraint: B <. A, which is a method constraint
|
||||||
*//*
|
*/
|
||||||
|
|
||||||
|
|
||||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||||
inputConstraints.add(new TPHConstraint("B", "A", TPHConstraint.Relation.EXTENDS));
|
inputConstraints.add(new TPHConstraint("B", "A", TPHConstraint.Relation.EXTENDS));
|
||||||
|
|
||||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> tphPositions = new HashMap<>();
|
HashMap<String, PairTphMethod<PositionFinder.Position, String>> tphPositions = new HashMap<>();
|
||||||
tphPositions.put("A", PositionFinder.Position.METHOD);
|
PairTphMethod<PositionFinder.Position, String> meth1 = new PairTphMethod<PositionFinder.Position, String>(PositionFinder.Position.METHOD, "m1");
|
||||||
tphPositions.put("B", PositionFinder.Position.METHOD);
|
tphPositions.put("A", meth1);
|
||||||
|
tphPositions.put("B", meth1);
|
||||||
|
|
||||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||||
assertTrue(classConstraints.isEmpty());
|
assertTrue(classConstraints.isEmpty());
|
||||||
|
|
||||||
*/
|
/*
|
||||||
/*
|
|
||||||
MethodConstraints should be the same as the input constraint
|
MethodConstraints should be the same as the input constraint
|
||||||
*//*
|
*//*
|
||||||
|
|
||||||
List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, tphPositions);
|
List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, tphPositions);
|
||||||
assertTrue(methodConstraints.size() == 1);
|
assertTrue(methodConstraints.size() == 1);
|
||||||
assertTrue(methodConstraints.get(0).getLeft().equals("B"));
|
assertTrue(methodConstraints.get(0).getLeft().equals("B"));
|
||||||
@ -44,8 +39,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testClassField(){
|
public void testClassField(){
|
||||||
*/
|
*//*
|
||||||
/*
|
|
||||||
class Example{
|
class Example{
|
||||||
A f;
|
A f;
|
||||||
B fReturn(){
|
B fReturn(){
|
||||||
@ -55,7 +49,6 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
gives constraint: A <. B, which is a class constraint
|
gives constraint: A <. B, which is a class constraint
|
||||||
*//*
|
*//*
|
||||||
|
|
||||||
|
|
||||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||||
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
|
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
|
||||||
|
|
||||||
@ -63,11 +56,9 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
tphPositions.put("A", PositionFinder.Position.FIELD);
|
tphPositions.put("A", PositionFinder.Position.FIELD);
|
||||||
tphPositions.put("B", PositionFinder.Position.METHOD);
|
tphPositions.put("B", PositionFinder.Position.METHOD);
|
||||||
|
|
||||||
*/
|
*//*
|
||||||
/*
|
|
||||||
ClassConstraints should not be the same as the input constraint
|
ClassConstraints should not be the same as the input constraint
|
||||||
*//*
|
*//*
|
||||||
|
|
||||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||||
System.out.println(classConstraints);
|
System.out.println(classConstraints);
|
||||||
assertTrue(classConstraints.size() == 2);
|
assertTrue(classConstraints.size() == 2);
|
||||||
@ -76,8 +67,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testSecondLineOfClassConstraints() {
|
public void testSecondLineOfClassConstraints() {
|
||||||
*/
|
*//*
|
||||||
/*
|
|
||||||
class Example() {
|
class Example() {
|
||||||
A a;
|
A a;
|
||||||
B b = a;
|
B b = a;
|
||||||
@ -93,7 +83,6 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
}
|
}
|
||||||
*//*
|
*//*
|
||||||
|
|
||||||
|
|
||||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||||
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
|
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
|
||||||
inputConstraints.add(new TPHConstraint("F", "C", TPHConstraint.Relation.EXTENDS));
|
inputConstraints.add(new TPHConstraint("F", "C", TPHConstraint.Relation.EXTENDS));
|
||||||
@ -117,8 +106,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testTPHsAndGenerics() {
|
public void testTPHsAndGenerics() {
|
||||||
*/
|
*//*
|
||||||
/*
|
|
||||||
class TPHsAndGenerics {
|
class TPHsAndGenerics {
|
||||||
Fun1<A,B> id = x -> x;
|
Fun1<A,B> id = x -> x;
|
||||||
C id2 (D x) {
|
C id2 (D x) {
|
||||||
@ -134,7 +122,6 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
}
|
}
|
||||||
*//*
|
*//*
|
||||||
|
|
||||||
|
|
||||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||||
inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS));
|
inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS));
|
||||||
inputConstraints.add(new TPHConstraint("B","C", TPHConstraint.Relation.EXTENDS));
|
inputConstraints.add(new TPHConstraint("B","C", TPHConstraint.Relation.EXTENDS));
|
||||||
@ -161,8 +148,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
|
|
||||||
assertFalse(classConstraints.isEmpty());
|
assertFalse(classConstraints.isEmpty());
|
||||||
assertTrue(classConstraints.size() == 3);
|
assertTrue(classConstraints.size() == 3);
|
||||||
}
|
}*/
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
public void testPositionConverter() {
|
public void testPositionConverter() {
|
||||||
@ -171,16 +157,22 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
|||||||
allTphsOld.put("A", true);
|
allTphsOld.put("A", true);
|
||||||
allTphsOld.put("B", false);
|
allTphsOld.put("B", false);
|
||||||
MethodAndTPH m1 = new MethodAndTPH("m1");
|
MethodAndTPH m1 = new MethodAndTPH("m1");
|
||||||
|
m1.getTphs().add("A");
|
||||||
|
MethodAndTPH bla = new MethodAndTPH("bla");
|
||||||
listOfMethodsAndTphs.add(new MethodAndTPH("bla"));
|
MethodAndTPH blubb = new MethodAndTPH("blubb");
|
||||||
listOfMethodsAndTphs.add(new MethodAndTPH("blubb"));
|
blubb.getTphs().add("A");
|
||||||
|
listOfMethodsAndTphs.add(bla);
|
||||||
|
listOfMethodsAndTphs.add(blubb);
|
||||||
listOfMethodsAndTphs.add(m1);
|
listOfMethodsAndTphs.add(m1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld, listOfMethodsAndTphs);
|
HashMap<String, PairTphMethod<PositionFinder.Position, String>> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld, listOfMethodsAndTphs);
|
||||||
System.out.println(allTphsNew);
|
System.out.println(allTphsNew);
|
||||||
|
//was tun wenn zwei (oder mehr) Methoden gleiches TPH enthalten?
|
||||||
|
//ist dies möglich oder werden die TPHs immer verschieden initialisiert und dann erst am Ende gemappt?
|
||||||
|
//überarbeiten oder lassen?
|
||||||
|
|
||||||
|
|
||||||
assertTrue(allTphsNew.get("A").fst.equals(PositionFinder.Position.METHOD));
|
assertTrue(allTphsNew.get("A").fst.equals(PositionFinder.Position.METHOD));
|
||||||
assertTrue(allTphsNew.get("B").fst.equals(PositionFinder.Position.FIELD));
|
assertTrue(allTphsNew.get("B").fst.equals(PositionFinder.Position.FIELD));
|
||||||
|
Loading…
Reference in New Issue
Block a user