Commit b50f518d authored by Camilo Cuadrado's avatar Camilo Cuadrado
Browse files

FEAT: primer commit para testear+ negate

parent d27e9766
......@@ -18,34 +18,61 @@ import java.util.Map;
* Por ejemplo, reemplaza "a > b" por "a <= b".
*/
public class NegateConditionsMutator extends MutationOperator {
@Override
public boolean isToBeProcessed(CtElement candidate) {
// COMPLETAR
if (!(candidate instanceof CtBinaryOperator)) {
return false;
}
private static final Map<BinaryOperatorKind, BinaryOperatorKind> NEGATIONS = new HashMap<>();
static {
NEGATIONS.put(BinaryOperatorKind.EQ, BinaryOperatorKind.NE);
NEGATIONS.put(BinaryOperatorKind.NE, BinaryOperatorKind.EQ);
NEGATIONS.put(BinaryOperatorKind.LT, BinaryOperatorKind.GE);
NEGATIONS.put(BinaryOperatorKind.GT, BinaryOperatorKind.LE);
NEGATIONS.put(BinaryOperatorKind.LE, BinaryOperatorKind.GT);
NEGATIONS.put(BinaryOperatorKind.GE, BinaryOperatorKind.LT);
CtBinaryOperator op = (CtBinaryOperator)candidate;
List<BinaryOperatorKind> targetOperations = Arrays.asList(
BinaryOperatorKind.EQ, // ==
BinaryOperatorKind.NE, // !=
BinaryOperatorKind.LE, // <=
BinaryOperatorKind.GE, // >=
BinaryOperatorKind.LT, // <
BinaryOperatorKind.GT // >
);
return targetOperations.contains(op.getKind());
}
@Override
/* @Override
public boolean isToBeProcessed(CtElement candidate) {
if (!(candidate instanceof CtBinaryOperator)) return false;
CtBinaryOperator<?> op = (CtBinaryOperator<?>) candidate;
return NEGATIONS.containsKey(op.getKind());
}
}**/
@Override
public void process(CtElement candidate) {
CtBinaryOperator<?> op = (CtBinaryOperator<?>) candidate;
op.setKind(getReplacement(op.getKind()));
}
/*
public BinaryOperatorKind getReplacement(BinaryOperatorKind kind) {
return NEGATIONS.get(kind);
}
*/
public BinaryOperatorKind getReplacement(BinaryOperatorKind kind) {
switch (kind) {
case EQ:
return BinaryOperatorKind.NE;
case NE:
return BinaryOperatorKind.EQ;
case LE:
return BinaryOperatorKind.GT;
case GE:
return BinaryOperatorKind.LT;
case LT:
return BinaryOperatorKind.GE;
case GT:
return BinaryOperatorKind.LE;
}
return null;
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment