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
Statement mutators: Assign, MethodCall #243
Conversation
1843c17
to
59450cd
Compare
This mutator tries to disable assignments, while trying to not to cause clear errors. This feat is achieved by prending an assignment with `true ||`, thus making the assignment essentially void.
59450cd
to
40b4dcd
Compare
These mutators replace any method or function call with `null`, `true`, or `false`. This way even if a method/funcion call is embedded in other construct, be it an `if` or another method call, there won't be a language error.
40b4dcd
to
d825097
Compare
9716cbd
to
c7d57ff
Compare
c7d57ff
to
d825097
Compare
Hi, sorry for the delay with the reply. About
|
No worries, we are not in a hurry with this PR, not at all. (But I really want you to consider #258) As was discussed in #53, primitive removal cannot be expected to give meaningful results. I understand you're looking at this mutator and see, like, woa, this mutator makes too much rubbish. What these do is way more clever that a simple removal. Where a simple removal would just remove the whole control struct with its descendants: +if ($foo = bar()) { /* */ }
- A statement mutator will keep all of it: +if ($foo = bar()) { /* */ }
-if (true || $foo = bar()) { /* still executed */ } So goes for other control structs and other mutators. But if you're only interested in control structs, you should be looking at them and only, right? +if ($foo = bar() && $baz = foo()) { /* */ }
-if ((true || $foo = bar()) && $baz = foo()) { /* */ }
-if ($foo = bar() && (true || $baz = foo())) { /* */ } The above example isn't possible within the current API within a single mutator. Let's remember that the whole purpose of mutation testing is to find weak spots in the test data, or |
Please excuse me if i'm wrong but it seems like it may be possible to limit mutators to insides of control structs. These's |
{ | ||
const REPLACEMENT = 'true'; | ||
|
||
public function mutate(Node $node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner to have an abstract MethodCall
mutator, and have MethodCallTrue
extend from that in the same way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Done.
This is probably worth looking into. My main concern with these mutators is that a lot of them will be duplicates, or get killed off due to language errors. |
should we close this one? seems like it's dead if it needs to be revised, I would suggest opening an RFC for each mutator separately, because currently, it's very hard to follow with so many things what is going on in this PR |
Yeah, that’s going to better. |
This PR:
Statement mutators
Statement mutators change or disable entire statements. Requested in #53.
Assign Statement mutator
This mutator tries to disable assignments, while trying to not to cause clear and straight errors. This feat is achieved by prepending an assignment with
true ||
, thus making the assignment essentially void.This code:
Becomes:
Assign mutator will only mutate if...
Constant assignments are left unscathed.
MethodCall Mutators
There's three mutators in this family: MethodCallFalse, MethodCallNull, MethodCallTrue.
These mutators replace any method or function call with
null
,true
, orfalse
. This way even if a method/function call is embedded in another construct, be it anif
or another method call, there won't be a language error.Becomes either of:
Instead of
$bar
there could be another method call that would not be mutated on this iteration. And there could be logical and instead of or: these mutators cover all bases.What gives?
Overall this should fix #53.
Please tell me if these are okay and I can go on with a doc PR.
BTW I'm OK if these mutators will go to the long discussed
@nightmare
profile since they add quite a lot of mutations.That's 4271 extra mutations to a thousand currently generated, but 401 escaped mutants and only 8 errors.
Errors
I'm not sure if these errors are avoidable: