stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.75k stars 176 forks source link

Range mutator #2922

Open richardwerkman opened 2 months ago

richardwerkman commented 2 months ago

Is your feature request related to a problem? Please describe. Range operator expressions are not mutated at the moment. Even though this contains crucial logic sometimes.

Describe the solution you'd like Original Mutated
.. 0
..end ..
..3 ..2
..3 ..4
start.. ..
2.. 1..
2.. 3..
start..end ..
2..2 1..2
2..2 3..2
2..2 2..1
2..2 2..3
^start.. ..
^2.. ^1..
^2.. ^3..
..^end ..
..^2 ..^1
..^2 ..^3
start..^end ..
2..^2 1..^2
2..^2 3..^2
2..^2 2..^1
2..^2 2..^3
^start..^end ..
^2..^2 ^3..^2
^2..^2 ^2..^1

So basically always replace with .. and if the start or end value is a declared value, increase this by one and decrease by one (check for bounds).

Additional context See: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/member-access-operators#range-operator-

rouke-broersma commented 2 months ago

Not sure we should implement the edge increase/decrease mutations, we don't do this for any other mutator either.

richardwerkman commented 2 months ago

We could also add/remove the ^? Would that make more sense?

dupdob commented 2 months ago

I do not think removing the 'relative to end' marker would create more interesting mutation than increment/decrement. On an implementation note, while the mutation seems simple to generate, controlling them will be a bit more difficult: I am not sure we can use a ternary operator with a range expression. but it should be a matter of adding a range expression orchestrator then