modified: src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java

modified:   src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java
	modified:   src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
toString wieder korrigiert

	modified:   src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java
	modified:   src/test/java/insertGenerics/TestAny.java
List -> Set
Bei allen anderen Tests fehlt es noch
This commit is contained in:
pl@gohorb.ba-horb.de 2021-03-25 19:55:16 +01:00
parent 91c075829b
commit d276c7c044
5 changed files with 9 additions and 51 deletions

View File

@ -65,7 +65,7 @@ public class TPHConstraint {
}
}
/*
@Override
public String toString() {
if(rel == Relation.EXTENDS) {
@ -74,13 +74,4 @@ public class TPHConstraint {
return left + " = " + right;
}
}
*/
public String toString() {
if(rel == Relation.EXTENDS) {
return "new TPHConstraint(\"" + left + "\", \"" + right + "\", Relation.EXTENDS)";
}
else {
return "new TPHConstraint(\"" + left + "\", \"" + right + "\", Relation.EQUAL)";
}
}
}

View File

@ -13,12 +13,4 @@ public class ClassConstraint extends TPHConstraint {
/*public ClassConstraint(TPHConstraint constraint) {
this.constraint = constraint;
}*/
public String toString() {
if(rel == Relation.EXTENDS) {
return "new ClassConstraint(\"" + left + "\", \"" + right + "\", Relation.EXTENDS)";
}
else {
return "new ClassConstraint(\"" + left + "\", \"" + right + "\", Relation.EQUAL)";
}
}
}

View File

@ -832,25 +832,6 @@ public class FamilyOfGeneratedGenerics {
return tempMethodConstraintsWithPosition;
}
public String toString() {
String ret =
"List<ClassConstraint> classConstraintsTest = new ArrayList<>();\n";
for(ClassConstraint cC: classConstraints) {
ret = ret + "classConstraintsTest.add(" + cC.toString() + ");\n";
}
ret = ret + "HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();\n";
ret = ret + "List<MethodConstraint> lmc;\n";
for (String methName : methodConstraintsWithPosition.keySet()) {
String consSet = "";
ret = ret + "lmc = new ArrayList<>();\n";
for (MethodConstraint methConstrs : methodConstraintsWithPosition.get(methName)) {
consSet = consSet + "lmc.add(" + methConstrs + ");\n";
}
ret = ret + consSet + "methodConstraintsWithPositionTest.put(\""+ methName + "\", lmc);\n";
}
return ret;
}
}

View File

@ -7,13 +7,4 @@ public class MethodConstraint extends TPHConstraint {
public MethodConstraint(String left, String right, Relation rel) {
super(left, right, rel);
}
public String toString() {
if(rel == Relation.EXTENDS) {
return "new MethodConstraint(\"" + left + "\", \"" + right + "\", Relation.EXTENDS)";
}
else {
return "new MethodConstraint(\"" + left + "\", \"" + right + "\", Relation.EQUAL)";
}
}
}

View File

@ -54,12 +54,12 @@ public class TestAny {
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<>();
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH RanyMethod()", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
methodConstraintsWithPositionTest.put("TPH UotherMethod(TPH U)", lmc);
FamilyOfGeneratedGenerics fogg = compiler.fogg;
@ -67,8 +67,11 @@ public class TestAny {
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
assertEquals(expectedClassCons, computedClassCons);
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionComputed = new HashMap<>();
fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l)));
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed);
//compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles);
for(File f : compiler.sourceFiles.keySet()){