use of spoon.test.replace.testclasses.Mole in project spoon by INRIA.
the class ReplaceTest method testReplaceBlockTry.
@Test
public void testReplaceBlockTry() throws Exception {
final CtType<Mole> aMole = buildClass(Mole.class);
final CtBlock<?> newBlock = aMole.getFactory().Code().createCtBlock(aMole.getFactory().Code().createCodeSnippetStatement("int j = 0;").compile());
final CtTry ctTry = aMole.getMethod("m").getElements(new TypeFilter<>(CtTry.class)).get(0);
assertNotEquals(newBlock, ctTry.getBody());
ctTry.getBody().replace(newBlock);
assertEquals(newBlock, ctTry.getBody());
}
Aggregations