From d276c7c0445b48f9e35b981c5c75dc065b12a3cf Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Thu, 25 Mar 2021 19:55:16 +0100 Subject: [PATCH] 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 --- .../bytecode/constraint/TPHConstraint.java | 11 +---------- .../insertGenerics/ClassConstraint.java | 8 -------- .../FamilyOfGeneratedGenerics.java | 19 ------------------- .../insertGenerics/MethodConstraint.java | 9 --------- src/test/java/insertGenerics/TestAny.java | 13 ++++++++----- 5 files changed, 9 insertions(+), 51 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java index ae51c18e..7e857600 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java @@ -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)"; - } - } } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java index afbae005..130f0ac6 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java @@ -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)"; - } - } } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 21b2c502..11c2a7c3 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -832,25 +832,6 @@ public class FamilyOfGeneratedGenerics { return tempMethodConstraintsWithPosition; } - - public String toString() { - String ret = - "List classConstraintsTest = new ArrayList<>();\n"; - for(ClassConstraint cC: classConstraints) { - ret = ret + "classConstraintsTest.add(" + cC.toString() + ");\n"; - } - ret = ret + "HashMap> methodConstraintsWithPositionTest = new HashMap<>();\n"; - ret = ret + "List 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; - } } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java index c0000f20..89533594 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/MethodConstraint.java @@ -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)"; - } - } } diff --git a/src/test/java/insertGenerics/TestAny.java b/src/test/java/insertGenerics/TestAny.java index e40c205e..9ef6d901 100644 --- a/src/test/java/insertGenerics/TestAny.java +++ b/src/test/java/insertGenerics/TestAny.java @@ -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> methodConstraintsWithPositionTest = new HashMap<>(); - List lmc; - lmc = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set 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 expectedClassCons = new HashSet<>(classConstraintsTest); assertEquals(expectedClassCons, computedClassCons); + + HashMap> 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()){