Skip to content

Commit

Permalink
fix: quote and dquote are discarded for the random char
Browse files Browse the repository at this point in the history
  • Loading branch information
danglotb committed Dec 18, 2016
1 parent eb9a750 commit 2e42624
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/main/java/fr/inria/diversify/dspot/amp/TestDataMutator.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,11 @@ protected List<CtMethod> createAllStringMutant(CtMethod method, CtLiteral litera
}


protected CtMethod createStringMutant(CtMethod method, int original_lit_index, String newValue) {
private CtMethod createStringMutant(CtMethod method, int original_lit_index, String newValue) {
dataCount++;
//clone the method
CtMethod cloned_method = AmplificationHelper.cloneMethod(method, "_literalMutation");
//get the lit_indexth literal of the cloned method
CtLiteral newLiteral = Query.getElements(cloned_method, new TypeFilter<CtLiteral>(CtLiteral.class))
.get(original_lit_index);

newLiteral.setValue(newValue);

Query.getElements(cloned_method, new TypeFilter<>(CtLiteral.class))
.get(original_lit_index).replace(cloned_method.getFactory().Code().createLiteral(newValue));
return cloned_method;
}

Expand Down Expand Up @@ -170,8 +165,10 @@ protected Set<String> stringMutated(CtLiteral literal) {
return values;
}

protected char getRandomChar() {
return (char) (AmplificationHelper.getRandom().nextInt(94) + 32);
private char getRandomChar() {
int value = AmplificationHelper.getRandom().nextInt(94) + 32;
char c = (char) ((value == 34 || value == 39) ? value + (AmplificationHelper.getRandom().nextBoolean() ? 1 : -1) : value);
return c;//excluding " and '
}

protected Set<? extends Number> numberMutated(CtLiteral literal) {
Expand Down

0 comments on commit 2e42624

Please sign in to comment.