I have to implement algorithm for finding mutants in code. From input file, i have to reading some code for example;
public static void main(String[] args){
int s = 0;
for (int i = 0; i < x.length; i++) {
s = s + x[i];
}
System.out.println(s);
}
I have to create mutants using two rules: replacement of arithmetic operations and replacement of variables of the same type. For example: in the code above we have line with code s=s+x[i];
The + sign should be replaced by the - sign, so the first mutant would be;
public static void main(String[] args){
int s = 0;
for (int i = 0; i < x.length; i++) {
s = s - x[i];
}
System.out.println(s);
}
Second mutant would be;
public static void main(String[] args){
int s = 0;
for (int i = 0; i < x.length; i++) {
s = s / x[i];
}
System.out.println(s);
}
And so for each sign. Do the same with replacement of variables of the same type.
Mutants must be written to the output file.
I need a solution in Java. Please help?
Aucun commentaire:
Enregistrer un commentaire