Skip to content

Commit

Permalink
Create a unit test to expose INRIA#1407
Browse files Browse the repository at this point in the history
  • Loading branch information
surli committed Jun 21, 2017
1 parent 1f6cd87 commit e880a0f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/java/spoon/test/generics/GenericsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import spoon.test.generics.testclasses.Orange;
import spoon.test.generics.testclasses.Paella;
import spoon.test.generics.testclasses.Panini;
import spoon.test.generics.testclasses.SameSignature;
import spoon.test.generics.testclasses.Spaghetti;
import spoon.test.generics.testclasses.Tacos;
import spoon.testing.utils.ModelUtils;
Expand Down Expand Up @@ -1094,4 +1095,24 @@ public void testGetDeclarationOfTypeParameterReference() {
assertSame(innerTotoFormatCtType.get(0), paramInnerToto.getDeclaration());
assertSame(innerTypeParametersList.get(0), returnInnerToto.getDeclaration());
}

@Test
public void testIsSameSignatureWithGenerics() {
Launcher launcher = new Launcher();
launcher.addInputResource("./src/test/java/spoon/test/generics/testclasses/SameSignature.java");
launcher.buildModel();

CtClass ctClass = launcher.getFactory().Class().get(SameSignature.class);

List<CtMethod> methods = ctClass.getMethodsByName("forEach");
assertEquals(1, methods.size());

CtType<?> iterableItf = launcher.getFactory().Type().get(Iterable.class);

List<CtMethod<?>> methodsItf = iterableItf.getMethodsByName("forEach");
assertEquals(1, methodsItf.size());

ClassTypingContext ctc = new ClassTypingContext(ctClass.getReference());
assertTrue(ctc.isSameSignature(methods.get(0), methodsItf.get(0)));
}
}
19 changes: 19 additions & 0 deletions src/test/java/spoon/test/generics/testclasses/SameSignature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package spoon.test.generics.testclasses;

import java.util.Iterator;
import java.util.function.Consumer;

/**
* Created by urli on 21/06/2017.
*/
public class SameSignature<T extends String> implements Iterable<T> {
@Override
public Iterator<T> iterator() {
return null;
}

@Override
public void forEach(Consumer<? super T> action) {

}
}

0 comments on commit e880a0f

Please sign in to comment.