diff --git a/src/test/java/insertGenerics/AllTests.java b/src/test/java/insertGenerics/TestMutualRecursion.java similarity index 90% rename from src/test/java/insertGenerics/AllTests.java rename to src/test/java/insertGenerics/TestMutualRecursion.java index f4f09992..30778032 100644 --- a/src/test/java/insertGenerics/AllTests.java +++ b/src/test/java/insertGenerics/TestMutualRecursion.java @@ -31,7 +31,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class AllTests { +public class TestMutualRecursion { private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; @@ -41,7 +41,7 @@ public class AllTests { private static String className; @Test - public void TestMutualRecursion() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + public void TestMutualRecursion1() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { className = "TestMutualRecursion"; JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+className+".jav")); List results = compiler.typeInference(); @@ -98,12 +98,6 @@ public class AllTests { execute(new File(rootDirectory+className+".jav")); } - @Test - public void TestContraVariant() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { - className = "TestContraVariant"; - execute(new File(rootDirectory+className+".jav")); - } - private static class TestResultSet{ } diff --git a/src/test/java/insertGenerics/TestTPHsAndGenerics.java b/src/test/java/insertGenerics/TestTPHsAndGenerics.java index 3c243171..9254100f 100644 --- a/src/test/java/insertGenerics/TestTPHsAndGenerics.java +++ b/src/test/java/insertGenerics/TestTPHsAndGenerics.java @@ -56,26 +56,50 @@ public class TestTPHsAndGenerics { List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); List classConstraintsTest = new ArrayList<>(); - classConstraintsTest.add(new ClassConstraint("UD", "DZP", Relation.EXTENDS)); - classConstraintsTest.add(new ClassConstraint("DZP", "ETW", Relation.EXTENDS)); - classConstraintsTest.add(new ClassConstraint("ETW", "java/lang/Object", Relation.EXTENDS)); HashMap> methodConstraintsWithPositionTest = new HashMap<>(); - List lmc; - lmc = new ArrayList<>(); - lmc.add(new MethodConstraint("AI", "AE", Relation.EXTENDS)); - lmc.add(new MethodConstraint("AD", "AI", Relation.EXTENDS)); - lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS)); - lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS)); - lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); - methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc); - lmc = new ArrayList<>(); - lmc.add(new MethodConstraint("V", "UD", Relation.EXTENDS)); - methodConstraintsWithPositionTest.put("TPH ETWid2(TPH V)", lmc); - lmc = new ArrayList<>(); - lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); - methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); FamilyOfGeneratedGenerics fogg = compiler.fogg; + + List lmc; + lmc = new ArrayList<>(); + + if (fogg.allConstraints.contains((new MethodConstraint("DZP", "ETW", Relation.EXTENDS)))) { + classConstraintsTest.add(new ClassConstraint("UD", "DZP", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("DZP", "ETW", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("ETW", "java/lang/Object", Relation.EXTENDS)); + + lmc.add(new MethodConstraint("AI", "AE", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AD", "AI", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc); + lmc = new ArrayList<>(); + lmc.add(new MethodConstraint("V", "UD", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ETWid2(TPH V)", lmc); + lmc = new ArrayList<>(); + lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); + } + else { + classConstraintsTest.add(new ClassConstraint("ETW", "DZP", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("DZP", "U", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("ETW", "java/lang/Object", Relation.EXTENDS)); + + lmc.add(new MethodConstraint("AI", "AE", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AD", "AI", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc); + lmc = new ArrayList<>(); + lmc.add(new MethodConstraint("V", "ETW", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ETWid2(TPH V)", lmc); + lmc = new ArrayList<>(); + lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); + } + Set computedClassCons = new HashSet<>(fogg.classConstraints); Set expectedClassCons = new HashSet<>(classConstraintsTest); diff --git a/src/test/java/insertGenerics/TestVector.java b/src/test/java/insertGenerics/TestVector.java index a020b279..b902e93e 100644 --- a/src/test/java/insertGenerics/TestVector.java +++ b/src/test/java/insertGenerics/TestVector.java @@ -63,6 +63,7 @@ public class TestVector { lmc.add(new MethodConstraint("ZU", "java/lang/Object", Relation.EXTENDS)); methodConstraintsWithPositionTest.put("voidm(java/util/Vectorjava/util/Vector)", lmc); lmc = new ArrayList<>(); + lmc.add(new MethodConstraint("W", "java/lang/Object", Relation.EXTENDS)); methodConstraintsWithPositionTest.put("TPH Wid(TPH W)", lmc); FamilyOfGeneratedGenerics fogg = compiler.fogg;