- Common ways to obtain CtLiteral
private void myMethod () {CtLiteral c =
CtLiteral ctLiteral;Object value;ctLiteral.setValue(value)
- Smart code suggestions by Codota
}
@Override public void revert() { newLiteral.replace(previousVariable); }
private CtMethod<?> createCharacterMutant(CtMethod method, int original_lit_index, Character newValue) { CtMethod cloned_method = CloneHelper.cloneTestMethodForAmp(method, "_literalMutationChar"); Counter.updateInputOf(cloned_method, 1); CtLiteral toReplace = Query.getElements(cloned_method.getBody(), new LiteralToBeMutedFilter()) .get(original_lit_index); toReplace.replace(cloned_method.getFactory().Code().createLiteral(newValue)); DSpotUtils.addComment(toReplace, "TestDataMutator on strings", CtComment.CommentType.INLINE); return cloned_method; }
private CtMethod<?> createStringMutant(CtMethod<?> method, int original_lit_index, String newValue) { CtMethod<?> cloned_method = CloneHelper.cloneTestMethodForAmp(method, "_literalMutationString"); Counter.updateInputOf(cloned_method, 1); CtLiteral toReplace = Query.getElements(cloned_method.getBody(), new LiteralToBeMutedFilter()) .get(original_lit_index); toReplace.replace(cloned_method.getFactory().Code().createLiteral(newValue)); DSpotUtils.addComment(toReplace, "TestDataMutator on strings", CtComment.CommentType.INLINE); return cloned_method; }
.getCatchers().contains(catches.get(0)) ) { ((CtLiteral<String>) failInvocation.get(0).getArguments().get(0)).replace( spoon.getFactory().createLiteral(PREFIX_MESSAGE_EXPECTED_EXCEPTION + exceptionName) );