Skip to content

Commit

Permalink
Fixed mutation of conditions not being applied to diagrams in some si…
Browse files Browse the repository at this point in the history
…tuations.
  • Loading branch information
fynndemmler committed Jan 24, 2024
1 parent a9091f1 commit e53eb04
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ protected void applyMutation(LinePair diffLine) throws CodeRepresentationFinderE
this.getMutantDiagrams().add(cd.getDiagram());
}

private String getConditionStr(String javaCondition) {
if (javaCondition.startsWith("while")) {
return javaCondition.substring("while (".length(), javaCondition.length() - ") {".length());
} else if (javaCondition.startsWith("if")) {
return javaCondition.substring("if (".length(), javaCondition.length() - ") {".length());
} else {
return javaCondition;
}
}

protected boolean changeTargetLine(Resource resource, LinePair diffLine) throws CodeRepresentationFinderException, IOException, MutatorException {
CbCFormula formula = getFormulaFrom(resource);
unproveEverything(formula.getStatement());
Expand All @@ -156,7 +166,7 @@ protected boolean changeTargetLine(Resource resource, LinePair diffLine) throws
if (crf.isContract()) {
targetC.setName(crf.transformJMLToJavaDL(diffLine.newLine));
} else {
targetC.setName(targetC.getName().replace(diffLine.originalLine, diffLine.newLine));
targetC.setName(targetC.getName().replace(getConditionStr(diffLine.originalLine), getConditionStr(diffLine.newLine)));
}
((AbstractStatement)target.eContainer()).setProven(false);
} else {
Expand Down

0 comments on commit e53eb04

Please sign in to comment.