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: test: add test for createReference #4078

Merged
merged 5 commits into from
Aug 10, 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
setType of the expectedRerence
Rohitesh-Kumar-Jain committed Aug 9, 2021
commit 7e74ce50f5afc9aeb2969ee4437e30c3907c3ede
10 changes: 5 additions & 5 deletions src/test/java/spoon/test/factory/MethodFactoryTest.java
Original file line number Diff line number Diff line change
@@ -38,23 +38,23 @@ public void testCreateReferenceWithActualMethod() throws ClassNotFoundException,
// contract: createReference creates a method reference of a actual method foo

// arrange
Factory factory = new Launcher().getFactory();
Launcher launcher = new Launcher();
Factory factory = launcher.getFactory();
Class<?> testClass = Class.forName("spoon.test.factory.testclasses.Bar");
Method testMethod = testClass.getMethod("foo");

CtExecutableReference<?> expectedReference = factory.createExecutableReference();
CtExecutableReference<Void> expectedReference = factory.createExecutableReference();
expectedReference.setSimpleName("foo");
CtTypeReference<?> ctTypeReference = factory.Type().createReference(Bar.class);
expectedReference.setDeclaringType(ctTypeReference);
CtTypeReference<?> typeReference = factory.Type().createReference(testMethod.getReturnType());
// expectedReference.setType(typeReference);
expectedReference.setType(launcher.getFactory().Type().voidPrimitiveType());

MethodFactory methodFactory = factory.Method();
CtExecutableReference<?> actualCreatedReference = null;

// act
actualCreatedReference = methodFactory.createReference(testMethod);

// assert
assertThat(actualCreatedReference, is(expectedReference));
}