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

Mutating "return true" with return true, imposible to kill the mutation #994

Closed
martinchaves opened this issue Mar 8, 2022 · 3 comments
Closed

Comments

@martinchaves
Copy link

Hi, we are having problems with the BooleanTrueReturnValsMutator.
We have a code like:

data.stream()
        .map(
            x -> {
              try {
                operation.accept(x);
                return true; // Mutated with BooleanTrueReturnValsMutator and BooleanFalseReturnValsMutator
              } catch (RuntimeException e) {
                return false; // Mutated only with BooleanTrueReturnValsMutator
              }
            })
        .reduce(true, Boolean::logicalAnd);

Because the method return true is mutated with a return true the mutation survives all test.
We only experienced this problem with lambdas with try/catch

Tested with gradle plugin 1.7.0, pitest 1.70 and 1.7.4, junit 5.8.2 with 0.15 junit plugin using JDK 8, 11 and 17.

I couldn't figure out if there are something wrong in our setup.
See the POC project.

@hcoles
Copy link
Owner

hcoles commented Mar 8, 2022

Thanks @kiov, I'll take a proper look in a moment, but at a first glance this looks like a bug. Equivalent mutants like this should be filtered out. I'm guessing the try catch block is tripping up pitest's analysis.

The POC project will be a big help - thanks for that.

@hcoles
Copy link
Owner

hcoles commented Mar 8, 2022

That was indeed a bug. The analysis didn't handle the additional label nodes added when an boxed boolean was returned from a try block.

Fix is merged, will be in the next release.

Thanks again.

@martinchaves
Copy link
Author

That was fast!!

My OCD with 100% coverage will be pleased 😁

Thanks you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants