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

Strange "empty-function-body into broken-array" mutation? #153

Closed
bkimminich opened this issue Sep 29, 2016 · 5 comments · Fixed by #160
Closed

Strange "empty-function-body into broken-array" mutation? #153

bkimminich opened this issue Sep 29, 2016 · 5 comments · Fixed by #160

Comments

@bkimminich
Copy link

image

This looks like it wants to mutate

angular.module('juiceShop').controller('AboutController', [
  function () {}])

into

angular.module('juiceShop').controller('AboutController', [
  function () { })

which doesn't seem like a good idea, syntax-wise with that missing closing angular bracket... or maybe it's just rendered wrong in the HTML report?

@bkimminich bkimminich changed the title Strange "empty-block to broken code" mutation? Strange "empty-function-body into broken-array" mutation? Sep 29, 2016
@simondel
Copy link
Member

simondel commented Oct 1, 2016

Is that this one?
image
If so, the clear-text reporter reports it as:
image
So it seems like an issue with the stryker-html-reporter. Perhaps Stryker and the stryker-html-reporter use a different definition of the column-number (start with column 1 or 0).

On a other note, perhaps the BlockStatementMutator should not mutate block statements if they are empty or only contain spaces. @nicojs Do you agree?

@nicojs
Copy link
Member

nicojs commented Oct 1, 2016

@simondel Well... in this case it does contain a 'use strict' statement. I agree that we shouldn't mutate it, it will always result in an equivalent mutant.

I created issue stryker-mutator/stryker-html-reporter#5 for the extra character. We'll keep this issue open to fix the equivalent mutant?

@bkimminich good find! Thanks for this issue!

@bkimminich
Copy link
Author

I did remove the 'use strict' because I thought that triggered the mutation. But it still mutated the empty block.

I would just ignore empty blocks, if anything other than statements (even comments!) is in a block, it should mutate. This kind of brought the useless 'use strict' with no subsequent code to my attention.

@nicojs
Copy link
Member

nicojs commented Oct 6, 2016

I just committed PR #160 to fix this issue. Unfortunately we cannot distinguish between an empty block or a block with only a comment. I choose to not mutate empty blocks in this case.

Just to be clear: "use strict"; is still mutated

@bkimminich
Copy link
Author

Fine for me. Plese ping me when I should re-test this!

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

Successfully merging a pull request may close this issue.

3 participants