use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteACaseOfASwitch.
@Test
public void testDeleteACaseOfASwitch() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m3");
final CtSwitch aSwitch = method.getElements(new TypeFilter<>(CtSwitch.class)).get(0);
final CtCase aCase = (CtCase) aSwitch.getCases().get(1);
assertEquals(2, aSwitch.getCases().size());
aCase.delete();
assertEquals(1, aSwitch.getCases().size());
assertFalse(aSwitch.getCases().contains(aCase));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteReturn.
@Test
public void testDeleteReturn() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m2");
assertEquals(1, method.getBody().getStatements().size());
final CtStatement statement = method.getBody().getStatement(0);
statement.delete();
assertEquals(0, method.getBody().getStatements().size());
assertFalse(method.getBody().getStatements().contains(statement));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class MethodTest method testClone.
@Test
public void testClone() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod<?> m2 = adobada.getMethod("m2");
CtMethod<?> clone = m2.clone();
clone.setVisibility(ModifierKind.PRIVATE);
assertEquals(ModifierKind.PUBLIC, m2.getModifiers().iterator().next());
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteAStatementInMethod.
@Test
public void testDeleteAStatementInMethod() throws Exception {
final Factory factory = build(Adobada.class);
final CtClass<Adobada> adobada = factory.Class().get(Adobada.class);
final CtMethod method = adobada.getMethod("m");
assertEquals(2, method.getBody().getStatements().size());
final CtStatement statement = method.getBody().getStatement(1);
statement.delete();
assertEquals(1, method.getBody().getStatements().size());
assertFalse(method.getBody().getStatements().contains(statement));
}
use of spoon.test.delete.testclasses.Adobada in project spoon by INRIA.
the class DeleteTest method testDeleteMethod.
@Test
public void testDeleteMethod() 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);
int n = adobada.getMethods().size();
// deleting m4
method.delete();
assertEquals(n - 1, adobada.getMethods().size());
assertFalse(adobada.getMethods().contains(method));
}
Aggregations