Stryker: Omitting condition section in standard for-loop breaks stryker

Created on 21 Oct 2016  路  7Comments  路  Source: stryker-mutator/stryker

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.

  1. git clone https://github.com/RachelSatoyama/bugreport.git
  2. cd bugreport/stryker-for-loop && npm install
  3. npm run stryker
馃悰 Bug

Most helpful comment

Yeah i agree with @RachelSatoyama . Could we mutate it to be for(;false;) ?

All 7 comments

Also 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:

  1. We don't mutate the code
  2. We pretend like it's a regular test statement

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeznag picture jeznag  路  6Comments

CheshireSwift picture CheshireSwift  路  4Comments

rodoabad picture rodoabad  路  5Comments

belmirofss picture belmirofss  路  4Comments

kmdrGroch picture kmdrGroch  路  5Comments