Add mutation for conditional (ternary) operator
See original GitHub issueIs your feature request related to a problem? Please describe. I have some code that prefixes a string conditionally:
val = val.Contains(prefix)
? val
: $"{prefix}{val}";
I have a test that checks that some strings without that prefix get prefixed, but I do not have any test that checks whether already prefixed strings also get that prefix added. Stryker didn’t find that issue as I expected it to.
Describe the solution you’d like
I propose adding two mutations for the conditional (ternary) operator:
Original: a ? b : c
Mutation 1: b
Mutation 2: c
Describe alternatives you’ve considered I can’t think of any.
Additional context None.
Issue Analytics
- State:
- Created 3 months ago
- Reactions:1
- Comments:12 (7 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 >Assigning apollo mutations with a ternary in an onClick?
I am currently having trouble with my login/registration component - a ternary operator is assigned to an onClick handler which dictates whether ...
Read more >Nested Ternaries are Great
When we force mutation or side-effects with if statements as opposed to ternaries, that often entails adding variables to the mix that don't ......
Read more >Use the Conditional (Ternary) Operator - Free Code Camp
In this tutorial we use the conditional ternary operator to make our JavaScript cleaner and more efficient. This is one video in a...
Read more >Use a Ternary Expression for Conditional Rendering - YouTube
In this React tutorial we use a ternary expression for conditional rendering. This video constitutes one part of many where I cover the ......
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
Cool stuff!
It took me a while to understand the missing piece here so here is the mutated code that Stryker wouldn’t flag:
Missing tests would be
yes, this will avoid having duplicate/similar mutants