Search in sources :

Example 1 with Join

use of spoon.test.loop.testclasses.Join in project spoon by INRIA.

the class LoopTest method testForeachShouldHaveAlwaysABlockInItsBody.

@Test
public void testForeachShouldHaveAlwaysABlockInItsBody() throws Exception {
    final CtClass<Join> aType = build(Join.class, Condition.class).Class().get(Join.class);
    final CtConstructor<Join> joinCtConstructor = aType.getConstructors().stream().findFirst().get();
    final CtLoop ctLoop = joinCtConstructor.getBody().getElements(new TypeFilter<>(CtLoop.class)).get(0);
    assertTrue(ctLoop.getBody() instanceof CtBlock);
    // 
    String expected = // 
    "for (spoon.test.loop.testclasses.Condition<? super T> condition : conditions)" + nl + "    this.conditions.add(spoon.test.loop.testclasses.Join.notNull(condition));" + nl;
    assertEquals(expected, ctLoop.toString());
}
Also used : CtBlock(spoon.reflect.code.CtBlock) Join(spoon.test.loop.testclasses.Join) TypeFilter(spoon.reflect.visitor.filter.TypeFilter) CtLoop(spoon.reflect.code.CtLoop) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CtBlock (spoon.reflect.code.CtBlock)1 CtLoop (spoon.reflect.code.CtLoop)1 TypeFilter (spoon.reflect.visitor.filter.TypeFilter)1 Join (spoon.test.loop.testclasses.Join)1