Ternary statement mutations
See original GitHub issueAt the moment, mutations are being placed inside if statements like this
if(Environment.GetEnvironmentVariable("ActiveMutation") == "<id>") {
// mutation
} else {
// original
}
Not all mutations can be inserted like this. Some mutations can only be inserted using ternary statements like this:
var localVariable = if(Environment.GetEnvironmentVariable("ActiveMutation") == "<id>") ? // mutation : //original
These kind of mutations should also be rollbacked different. My suggestion is an interface for both type of mutant placements. Something like:
public interface IMutantPlacement {
SyntaxNode InsertMutant(SyntaxNode, Mutant);
SyntaxNode RemoveMutant(SyntaxNode, Mutant);
}
It would have two implementations. One for if statements and one for ternary mutations.
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
Add mutation for conditional (ternary) operator · Issue #757
I propose adding a mutation for conditional operator: Original Mutated a ? b : c a ? c : b Also, I am...
Read more >Nested Ternaries are Great
In functional programming, we tend to avoid mutations and other side-effects. Since if in JavaScript naturally affords mutation and side effects ...
Read more >Assigning apollo mutations with a ternary in an onClick?
Using react-apollo, how to define 2 mutations in the same component with TypeScript? 7 · How to type a mutation in typescript +...
Read more >Using Conditional Mutation to Increase the Efficiency of ...
Another do smarter ap- proach is weak mutation testing [8] where a mutant is said to be killed if its internal state, after...
Read more >Why I'm phasing out ternary statements
Why I've stopped using ternary statements. ... Variables that can be mutated add mental load and make the program harder to follow.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Alright, I think I have things working. We end up using ternary mutations for expressions and if mutations only for statements, which means a lot more ternary mutations but often a lot less code overall.
I have a proof of concept (with some new tests and all tests passing) at https://github.com/kevinlyles/stryker-net/tree/issue-17, but I probably won’t have time to clean things up until next week. Feel free to have a look, and let me know what you think.
Well the type LocalFunctionStatement can contain a
Body
,or an
ExpressionBody
One should be mutated by IfStatements, the other by ConditionalExpression. But I think I have figured out a way to nicely handle this.