Hinzufpgen von Signatur- und Descriptor-Tests für TPHs als Typargumente in Funktionstypen.

This commit is contained in:
Etienne Zink 2022-04-08 08:22:08 +02:00
parent 722d897d4b
commit a0367d5464
2 changed files with 26 additions and 8 deletions

View File

@ -26,7 +26,6 @@ public class Resolver {
return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor()); return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor());
} }
//ToDo Etienne: Check ob benötigt
public RefTypeOrTPHOrWildcardOrGeneric resolve(RefTypeOrTPHOrWildcardOrGeneric type) { public RefTypeOrTPHOrWildcardOrGeneric resolve(RefTypeOrTPHOrWildcardOrGeneric type) {
return resultSet.resolveType(type).resolvedType; return resultSet.resolveType(type).resolvedType;
} }

View File

@ -19,13 +19,19 @@ import static org.objectweb.asm.Opcodes.*;
public class FunNGeneratorTest { public class FunNGeneratorTest {
static FunNUtilities funNGenerator; static FunNUtilities funNGenerator;
static RefType voidType = new RefType(new JavaClassName(Type.getInternalName(Void.class)), null); static RefType voidType;
static RefType integerType = new RefType(new JavaClassName(Type.getInternalName(Integer.class)), null); static RefType integerType;
static GenericRefType genericT = new GenericRefType("T", null); static GenericRefType genericT;
static TypePlaceholder tph;
@BeforeClass @BeforeClass
public static void setUp(){ public static void setUp(){
funNGenerator = FunNGenerator.getInstance(); 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 @Test
@ -82,18 +88,31 @@ public class FunNGeneratorTest {
assertEquals("LFun1$$Ljava$lang$Integer$_$LT$_$<TT;>;", classSignature); assertEquals("LFun1$$Ljava$lang$Integer$_$LT$_$<TT;>;", classSignature);
} }
@Test
public void signature_TPHTPH(){
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph);
assertEquals(String.format("LFun1$$LTPH$_$LTPH$_$<T%s$;T%s$;>;",tph.getName(), tph.getName()), classSignature);
}
@Test @Test
public void descriptor_IntInt(){ 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 //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 @Test
public void descriptor_IntT(){ 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 //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 @Test