Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linq mutators for Union, Intersect, Concat & Except #1038

Closed
jnyrup opened this issue Apr 17, 2020 · 3 comments
Closed

linq mutators for Union, Intersect, Concat & Except #1038

jnyrup opened this issue Apr 17, 2020 · 3 comments
Labels
🚀 Feature request New feature or request

Comments

@jnyrup
Copy link

jnyrup commented Apr 17, 2020

I was wondering how to mutate code that involved the following LINQ methods

  • Union()
  • Intersect()
  • Concat()
  • Except()

One idea was this mapping

Original Mutated
Union() Intersect()
Intersect() Union()
Concat() Except()
Except() Concat()

Alternatively would it be within the scope of Stryker or possible at all, to mutate the IEnumerable<T> parameter with Enumerable.Empty<T>()?

@jnyrup jnyrup added the 🚀 Feature request New feature or request label Apr 17, 2020
@richardwerkman
Copy link
Member

I Like these additions to the linq mutator. I'm not sure what your plan is with the Enumerable.Empty<T>(). Should it replace the whole linq query?

If you'd like to help us more with our mutators you could check out this issue: stryker-mutator/stryker-handbook#33

@jnyrup
Copy link
Author

jnyrup commented Apr 20, 2020

@richardwerkman
My idea with Enumerable.Empty<T>() was to introduce two mutants of e.g. a.Concat(b):

  • Enumerable.Empty<T>().Concat(b)
  • a.Concat(Enumerable.Empty<T>())

I had a look at the other issue, but I don't really have any opinions on mutant levels, except that it sounds useful.

@richardwerkman
Copy link
Member

That could prove hard as these methods are not always directly called on the list itself. They are often called like:

a.ToList().Concat(b);

which would become:

a.Enumerable.Empty<T>().Concat(b)

That would not compile of couse. I think swapping the methods with their "opposite" method does the job as well and is a much easier mutation. So I'd rather go for your first suggestion.

And thanks for taking a look at the other issue, good to know it sounds useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants