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

Avoid using "true" condition replacement in "||" statements, and avoid using "false" replacement in "&&" statements #3339

Closed
edi9999 opened this issue Jan 7, 2022 · 2 comments · Fixed by #3346
Labels
🚀 Feature request New feature request

Comments

@edi9999
Copy link
Contributor

edi9999 commented Jan 7, 2022

Is your feature request related to a problem? Please describe.

I have some code like this :

if (part.type === "content" || part.type === "tag") {
    return part;
}

And there are 3 applied mutants :

if (true) {
    return part;
}

if (true || part.type === "tag") {
    return part;
}
if (part.type === "content" || true) {
    return part;
}

I think it would make sense to just run one of the mutants in this case.

@edi9999 edi9999 added the 🚀 Feature request New feature request label Jan 7, 2022
@edi9999
Copy link
Contributor Author

edi9999 commented Jan 7, 2022

Could you pinpoint a point in the code where we have access to all mutants on one file for example to see if we could check for those cases ?

@nicojs
Copy link
Member

nicojs commented Jan 8, 2022

Having all mutants available for one file is too late IMO. You won't have access to the AST anymore, which is what you need. Seeing as all these get created by the same mutator, we should try to simply not make the similar mutants at all. So I would suggest looking at the mutator implementation.

Please change the title of this issue, equivalent mutants are something entirely different, see https://stryker-mutator.io/docs/mutation-testing-elements/equivalent-mutants

@edi9999 edi9999 changed the title Avoid "equivalent mutants" Avoid using "true" condition replacement in or statements, and avoid using "false" replacement in and statements Jan 8, 2022
@edi9999 edi9999 changed the title Avoid using "true" condition replacement in or statements, and avoid using "false" replacement in and statements Avoid using "true" condition replacement in "||" statements, and avoid using "false" replacement in "&&" statements Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature request New feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants