Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review: bug(*): fix method resolution for inner interfaces #4008

Merged
merged 5 commits into from
Jun 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move testcase
MartinWitt committed Jun 28, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 691ce46371cb06c3dcd5a254137b3684a54315eb
19 changes: 18 additions & 1 deletion src/test/java/spoon/test/ctType/CtTypeTest.java
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.test.ctType.testclasses.X;

import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -46,6 +45,9 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
@@ -267,4 +269,19 @@ public void testTypeDeclarationToReferenceRoundTripInNamedModule() {

assertSame(reFetchedTypeDecl, typeDecl);
}
@Test
public void testGetAllExecutablesOnTypeImplementingNestedInterface() {
// contract: implicit static nested interfaces are correct handled in getAllExecutables.
Launcher launcher = new Launcher();
launcher.addInputResource("src/test/resources/extendsStaticInnerType");
CtModel model = launcher.buildModel();
CtType<?> type = model.getAllTypes().stream().filter(v -> v.getSimpleName().contains("BarBaz")).findAny().get();
int expectedNumExecutablesInJDK8 = 13;
int expectedNumExecutablesPostJDK8 = 14;
int numExecutables = type.getAllExecutables().size();
assertThat(numExecutables, anyOf(
equalTo(expectedNumExecutablesInJDK8),
equalTo(expectedNumExecutablesPostJDK8))
);
}
}
16 changes: 1 addition & 15 deletions src/test/java/spoon/test/executable/ExecutableTest.java
Original file line number Diff line number Diff line change
@@ -130,19 +130,5 @@ public void testShadowValueOf() {
new ContractVerifier(shadowValueOf.getParent(CtPackage.class)).checkShadow();
}

@Test
public void testGetAllExecutablesOnTypeImplementingNestedInterface() {
// contract: implicit static nested interfaces are correct handled in getAllExecutables.
Launcher launcher = new Launcher();
launcher.addInputResource("src/test/resources/extendsStaticInnerType");
CtModel model = launcher.buildModel();
CtType<?> type = model.getAllTypes().stream().filter(v -> v.getSimpleName().contains("BarBaz")).findAny().get();
int expectedNumExecutablesInJDK8 = 13;
int expectedNumExecutablesPostJDK8 = 14;
int numExecutables = type.getAllExecutables().size();
assertThat(numExecutables, anyOf(
equalTo(expectedNumExecutablesInJDK8),
equalTo(expectedNumExecutablesPostJDK8))
);
}

}