use of spoon.reflect.declaration.CtTypedElement in project spoon by INRIA.
the class GenericsTest method testCtTypeReference_getSuperclass.
@Test
public void testCtTypeReference_getSuperclass() throws Exception {
Factory factory = build(new File("src/test/java/spoon/test/generics/testclasses"));
CtClass<?> ctClassCelebrationLunch = factory.Class().get(CelebrationLunch.class);
CtTypeReference<?> trWeddingLunch_Mole = ctClassCelebrationLunch.filterChildren(new NamedElementFilter<>(CtNamedElement.class, "disgust")).map((CtTypedElement te) -> {
return te.getType();
}).first();
assertEquals("spoon.test.generics.testclasses.CelebrationLunch<java.lang.Integer, java.lang.Long, java.lang.Double>.WeddingLunch<spoon.test.generics.testclasses.Mole>", trWeddingLunch_Mole.toString());
CtType<?> tWeddingLunch_X = trWeddingLunch_Mole.getDeclaration();
CtTypeReference<?> trCelebrationLunch_Tacos_Paella_X = tWeddingLunch_X.getSuperclass();
// current correct behavior of CtType#getSuperclass()
assertEquals("spoon.test.generics.testclasses.CelebrationLunch<" + "spoon.test.generics.testclasses.Tacos, " + "spoon.test.generics.testclasses.Paella, " + "X" + ">", trCelebrationLunch_Tacos_Paella_X.toString());
// current - wrong behavior of CtTypeReference#getSuperclass()
assertEquals("spoon.test.generics.testclasses.CelebrationLunch<" + "spoon.test.generics.testclasses.Tacos, " + "spoon.test.generics.testclasses.Paella, " + "X" + ">", trWeddingLunch_Mole.getSuperclass().toString());
// future suggested behavior of CtTypeReference#getSuperclass() - the 3rd argument is Mole.
// assertEquals("spoon.test.generics.testclasses.CelebrationLunch<"
// + "spoon.test.generics.testclasses.Tacos, "
// + "spoon.test.generics.testclasses.Paella, "
// + "spoon.test.generics.testclasses.Mole"
// + ">",trWeddingLunch_Mole.getSuperclass().toString());
// future suggested behavior of CtTypeReference#getSuperclass()
// assertEquals("spoon.test.generics.testclasses.Lunch<"
// + "spoon.test.generics.testclasses.Mole, "
// + "spoon.test.generics.testclasses.Tacos"
// + ">",trWeddingLunch_Mole.getSuperclass().getSuperclass().toString());
}
Aggregations