use of spoon.test.targeted.testclasses.Tapas in project spoon by INRIA.
the class TargetedExpressionTest method testClassDeclaredInALambda.
@Test
public void testClassDeclaredInALambda() throws Exception {
// contract: A class can be declared in a lambda expression where we use final fields.
final CtType<Tapas> type = buildClass(Tapas.class);
final List<CtFieldAccess> elements = new SortedList(new CtLineElementComparator());
elements.addAll(type.getElements(new TypeFilter<>(CtFieldAccess.class)));
assertEquals(3, elements.size());
final CtTypeReference<Object> firstExpected = type.getFactory().Type().createReference("spoon.test.targeted.testclasses.Tapas$1$InnerSubscriber");
CtThisAccess<Object> expectedThisAccess = type.getFactory().Code().createThisAccess(firstExpected);
assertEqualsFieldAccess(new ExpectedTargetedExpression().declaringType(firstExpected).target(expectedThisAccess).type(CtFieldWrite.class).result("this.index"), elements.get(0));
final CtTypeReference<Object> secondExpectedInner = type.getFactory().Type().createReference("spoon.test.targeted.testclasses.Tapas$3InnerSubscriber");
expectedThisAccess = type.getFactory().Code().createThisAccess(secondExpectedInner);
assertEqualsFieldAccess(new ExpectedTargetedExpression().declaringType(secondExpectedInner).target(expectedThisAccess).type(CtFieldWrite.class).result("this.index").isLocal(), elements.get(1));
final CtTypeReference<Object> thirdExpectedInner = type.getFactory().Type().createReference("spoon.test.targeted.testclasses.Tapas$4InnerSubscriber");
expectedThisAccess = type.getFactory().Code().createThisAccess(thirdExpectedInner);
assertEqualsFieldAccess(new ExpectedTargetedExpression().declaringType(thirdExpectedInner).target(expectedThisAccess).type(CtFieldWrite.class).result("this.index").isLocal(), elements.get(2));
}
Aggregations