use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteChainOfAssignment.
@Test
public void testDeleteChainOfAssignment() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m4", factory.Type().INTEGER_PRIMITIVE, factory.Type().FLOAT_PRIMITIVE, factory.Type().STRING);
final CtAssignment chainOfAssignment = method.getElements(new TypeFilter<>(CtAssignment.class)).get(0);
assertNotNull(chainOfAssignment.getAssignment());
chainOfAssignment.getAssignment().delete();
assertNull(chainOfAssignment.getAssignment());
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteAStatementInStaticAnonymousExecutable.
@Test
public void testDeleteAStatementInStaticAnonymousExecutable() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final List<CtAnonymousExecutable> anonymousExecutables = adobada.getAnonymousExecutables();
final CtAnonymousExecutable staticExec = anonymousExecutables.get(1);
assertEquals(2, staticExec.getBody().getStatements().size());
final CtStatement statement = staticExec.getBody().getStatement(1);
statement.delete();
assertEquals(1, staticExec.getBody().getStatements().size());
assertFalse(staticExec.getBody().getStatements().contains(statement));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteConditionInACondition.
@Test
public void testDeleteConditionInACondition() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m4", factory.Type().INTEGER_PRIMITIVE, factory.Type().FLOAT_PRIMITIVE, factory.Type().STRING);
final CtIf anIf = method.getElements(new TypeFilter<>(CtIf.class)).get(0);
assertNotNull(anIf.getCondition());
anIf.getCondition().delete();
assertNull(anIf.getCondition());
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteAStatementInConstructor.
@Test
public void testDeleteAStatementInConstructor() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtConstructor<Adobada> constructor = adobada.getConstructor();
assertEquals(3, constructor.getBody().getStatements().size());
final CtStatement statement = constructor.getBody().getStatement(1);
statement.delete();
assertEquals(2, constructor.getBody().getStatements().size());
assertFalse(constructor.getBody().getStatements().contains(statement));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteStatementInCase.
@Test
public void testDeleteStatementInCase() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m3");
final CtCase aCase = method.getElements(new TypeFilter<>(CtCase.class)).get(0);
assertEquals(2, aCase.getStatements().size());
final CtStatement statement = aCase.getStatements().get(1);
statement.delete();
assertEquals(1, aCase.getStatements().size());
assertFalse(aCase.getStatements().contains(statement));
}
Aggregations