Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
laureano Navarro
isw2-2025-2c
Commits
b50f518d
Commit
b50f518d
authored
Aug 20, 2025
by
Camilo Cuadrado
Browse files
FEAT: primer commit para testear+ negate
parent
d27e9766
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
11 deletions
+38
-11
StackAr/src/main/java/org/autotest/operators/binary/NegateConditionsMutator.java
...rg/autotest/operators/binary/NegateConditionsMutator.java
+38
-11
No files found.
StackAr/src/main/java/org/autotest/operators/binary/NegateConditionsMutator.java
View file @
b50f518d
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment