When you have a code like this:
for(let i=0;;i++) {
actual behaviour
stryker will fail with:
[2016-10-21 17:53:14.612] [ERROR] stryker-cli - an error occurred Error: The mutator named 'RemoveConditionals' caused an error: TypeError: Cannot read property 'nodeID' of null
expected behaviour
What is expected: stryker does not supposed to fail in this case. While it's not idiomatic (and most probably could be rewritten in a more readable fashion) this is 100% valid code.
if there will be any valid expression condition expression in for loop, this will work, so it's enought to have:
for(let i=0;true;i++) {
how to reproduce
I've created a minimal example.
git clone https://github.com/RachelSatoyama/bugreport.gitcd bugreport/stryker-for-loop && npm installnpm run strykerAlso I'm not sure I can add labels here so I apologize I hadn't added "bug" label.
That's... interesting. What the RemoveConditionalsMutator does is looks at certain types of nodes such as ForStatement nodes. Those nodes have a property test but if it's empty... it's actually null.
So there are two options:
What do you think @nicojs and @RachelSatoyama ?
Well, personally I'd rather go with option #2 - after all this is indeed just an accepted (yet quite exotic) way to write while(true)
Yeah i agree with @RachelSatoyama . Could we mutate it to be for(;false;) ?
Is there anything blocking this fix from being released?
I just released it :) It should be fixed when using version 0.5.7 of Stryker
It is. Thanks!
Most helpful comment
Yeah i agree with @RachelSatoyama . Could we mutate it to be
for(;false;)?