From a0367d5464c345dc97ec7351cc620e1208477152 Mon Sep 17 00:00:00 2001 From: Etienne Zink Date: Fri, 8 Apr 2022 08:22:08 +0200 Subject: [PATCH] =?UTF-8?q?Hinzufpgen=20von=20Signatur-=20und=20Descriptor?= =?UTF-8?q?-Tests=20f=C3=BCr=20TPHs=20als=20Typargumente=20in=20Funktionst?= =?UTF-8?q?ypen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bytecode/utilities/Resolver.java | 1 - .../java/bytecode/funN/FunNGeneratorTest.java | 33 +++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/utilities/Resolver.java b/src/main/java/de/dhbwstuttgart/bytecode/utilities/Resolver.java index 684fdd4b..035b9710 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/utilities/Resolver.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/utilities/Resolver.java @@ -26,7 +26,6 @@ public class Resolver { return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor()); } - //ToDo Etienne: Check ob benötigt public RefTypeOrTPHOrWildcardOrGeneric resolve(RefTypeOrTPHOrWildcardOrGeneric type) { return resultSet.resolveType(type).resolvedType; } diff --git a/src/test/java/bytecode/funN/FunNGeneratorTest.java b/src/test/java/bytecode/funN/FunNGeneratorTest.java index b1e14cf0..f465a0ff 100644 --- a/src/test/java/bytecode/funN/FunNGeneratorTest.java +++ b/src/test/java/bytecode/funN/FunNGeneratorTest.java @@ -19,13 +19,19 @@ import static org.objectweb.asm.Opcodes.*; public class FunNGeneratorTest { static FunNUtilities funNGenerator; - static RefType voidType = new RefType(new JavaClassName(Type.getInternalName(Void.class)), null); - static RefType integerType = new RefType(new JavaClassName(Type.getInternalName(Integer.class)), null); - static GenericRefType genericT = new GenericRefType("T", null); + static RefType voidType; + static RefType integerType; + static GenericRefType genericT; + static TypePlaceholder tph; @BeforeClass public static void setUp(){ + funNGenerator = FunNGenerator.getInstance(); + voidType = new RefType(new JavaClassName(Type.getInternalName(Void.class)), null); + integerType = new RefType(new JavaClassName(Type.getInternalName(Integer.class)), null); + genericT = new GenericRefType("T", null); + tph = TypePlaceholder.fresh(null); } @Test @@ -82,18 +88,31 @@ public class FunNGeneratorTest { assertEquals("LFun1$$Ljava$lang$Integer$_$LT$_$;", classSignature); } + @Test + public void signature_TPHTPH(){ + var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph); + assertEquals(String.format("LFun1$$LTPH$_$LTPH$_$;",tph.getName(), tph.getName()), classSignature); + } + @Test public void descriptor_IntInt(){ - var classSignature = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), integerType); + var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), integerType); //does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well - assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", classSignature); + assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", classDescriptor); } @Test public void descriptor_IntT(){ - var classSignature = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), genericT); + var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), genericT); //does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well - assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", classSignature); + assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", classDescriptor); + } + + @Test + public void descriptor_TPHTPH(){ + var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(tph), tph); + //does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well + assertEquals("Fun1$$LTPH$_$LTPH$_$", classDescriptor); } @Test