Skip to content

Commit

Permalink
Refactored test to be more descriptive.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Oct 17, 2016
1 parent cf4c0b1 commit 89243c8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 22 deletions.
Expand Up @@ -197,16 +197,6 @@ public void testInterfaceType() throws Exception {
assertThat(createdType.getInterfaces(), is(originalType.getInterfaces()));
}

@Test
public void testNestedTypeVariable() throws Exception {
// Requires erasure of out-of-scope variables.
TypeDescription typeDescription = new ByteBuddy()
.redefine(AbstractOuter.ExtendedInner.class)
.make()
.getTypeDescription();
assertThat(typeDescription.getTypeVariables().isEmpty(), is(true));
}

public abstract static class GenericType<T extends ArrayList<T> & Callable<T>,
S extends Callable<?>,
U extends Callable<? extends Callable<U>>,
Expand Down Expand Up @@ -267,16 +257,4 @@ public static class TypeVariableWildcardLowerInterfaceBound<T extends ArrayList<
public interface InterfaceType<T> extends Callable<T> {
/* empty */
}

public static abstract class AbstractOuter<T> {

public abstract class Inner {

public abstract T foo();
}

public abstract class ExtendedInner extends Inner {
/* empty */
}
}
}
Expand Up @@ -1245,6 +1245,33 @@ public void testInconsistentReceiverConstructorInnerClass() throws Exception {
.validated();
}

@Test
public void testTypeVariableOutOfScopeIsErased() throws Exception {
TypeDescription typeDescription = new InstrumentedType.Default("foo",
Opcodes.ACC_PUBLIC,
new TypeDescription.Generic.OfNonGenericType.ForLoadedType(AbstractOuter.ExtendedInner.class),
Collections.<TypeVariableToken>emptyList(),
Collections.<TypeDescription.Generic>emptyList(),
Collections.<FieldDescription.Token>emptyList(),
Collections.singletonList(new MethodDescription.Token("foo",
Opcodes.ACC_BRIDGE,
TypeDescription.Generic.VOID,
Collections.<TypeDescription.Generic>emptyList())),
Collections.<AnnotationDescription>emptyList(),
TypeInitializer.None.INSTANCE,
LoadedTypeInitializer.NoOp.INSTANCE,
TypeDescription.UNDEFINED,
MethodDescription.UNDEFINED,
TypeDescription.UNDEFINED,
Collections.<TypeDescription>emptyList(),
false,
false,
false);
MethodDescription methodDescription = typeDescription.getSuperClass().getSuperClass().getDeclaredMethods().filter(named(FOO)).getOnly();
assertThat(methodDescription.getReturnType(), is(TypeDescription.Generic.OBJECT));

}

public @interface SampleAnnotation {
/* empty */
}
Expand All @@ -1257,4 +1284,16 @@ public void testInconsistentReceiverConstructorInnerClass() throws Exception {
private class Foo {
/* empty */
}

public static abstract class AbstractOuter<T> {

public abstract class Inner {

public abstract T foo();
}

public abstract class ExtendedInner extends Inner {
/* empty */
}
}
}

0 comments on commit 89243c8

Please sign in to comment.