Open C0DK opened 2 years ago
I'm open to extra Linq mutations, we do the same for Binary mutations. Could you think of more extra mutations that would add value? It would be nice to think of all mutations before anyone starts working on this
I started adding the followings (but realized it would entail some refactorings, and wanted a greenlight from you guys):
(and all the same operations for the OrDefault
variants.
I'm not sure if I have others, but if we/you Change the KindsToMutate
to a Dictionary<LinqExpression, LinqExpression[]>
, then I'll be easy to add additional ones, and I'll promise to open a PR if I realize some other case that would be fun.
we need to evaluate the risk of un-killable mutations which are (often) linked to semantically equivalent code.
In your examples, I am pretty sure that Single
mutations will be un-killable: if Single
returns a result, First
and Last
will.
The only change will be when Single
is used on an enumeration containing more than one item, it will throws, whereas First
and Last
will work. So Single
seems not interesting to mutate, and if you do it, there is no benefit in trying both First
and Last
.
Mutating First
and Last
to Single
is interesting, because if the mutant survives, the coder can either adjust its test to ensure there is more than one entry in its enumeration, or it can switch to Single
if there is always a single entry.
That being said, I suspect this mutant will often be killed simply because there is more than one entry in the enumeration.
hmm true, that are good points.
More mutations for each linq expression.
I.e: First is not just mutated to FirstOrDefault, but also Last and Single.
Currently, you guys have a one-to-one mapping of possible mutations given a Linq expression. I realized that I had a few places where I used First but never tested what would happen if multiple values were returned. A mapping from
first -> last
would be nice. This, however, Is currently not possible with the way LinqMutator.cs is written. A nested loop would be a solution, but would naturally create more mutations (are we interested in that?) but it might catch more different cases...