Open ryanfreckleton opened 3 years ago
Seems reasonable. Would you like to give it a shot to implement this?
Sure! Apologies for the late response.
I’ll post right before I start implementing, in case anyone else wants to take it on.
I would love to see this get done. My workaround is to keep a special git stash of changes to replace all ternaries with expanded if/else blocks. And mutation testing with this stash of changes did give me a surviving mutant in some private code I was working on. (I actually use my own fork with some extra hackage to raise a RuntimeError in case it finds any ternaries in the code to mutate.)
When I tried hacking in the existing code, it looks like the code in __init__.py
can handle multiple mutations of single tokens such as operators, but not for anything bigger at this time. I am sure it should be pretty straightforward to update the code to support multiple mutations of larger pieces of code, unfortunately I have not yet succeeded with this.
Ternary operator errors of not covering both branches can't be detected by coverage, so it would be useful to mutate these to enable/disable each branch. E.g.
mutation into:
and
This types of mutations aren't as useful for normal if statements, because branch coverage can detect when one of the alternatives isn't covered.