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

Math mutator: Don't mutate string concatenation '+' #10

Open
DiegoRBaquero opened this issue Apr 25, 2018 · 7 comments
Open

Math mutator: Don't mutate string concatenation '+' #10

DiegoRBaquero opened this issue Apr 25, 2018 · 7 comments

Comments

@DiegoRBaquero
Copy link
Member

No description provided.

@simondel
Copy link

Why not? It's valid JavaScript.

@DiegoRBaquero
Copy link
Member Author

Valid JavaScript but results in NaN. Easily caught while coding, when failing to see the expected text or by a linter. Saves many mutators when there are many concatenations -> saves time.

@simondel
Copy link

True, but how big of an issue is this in modern JavaScript code? Since you won't have this issue with template strings.

@DiegoRBaquero
Copy link
Member Author

Small, even more reason to not mutate it as template strings take over.

@simondel
Copy link

👍 your call. You could also keep it in to encourage devs to switch to template strings.

In the case of Stryker, the only complaints we got from mutating string concatenation was from TypeScript users and we fixed that by using the TypeScript compiler together with the projects tsconfig.json to determine which code would cause a transpiler error.

@DiegoRBaquero
Copy link
Member Author

This I like

You could also keep it in to encourage devs to switch to template strings.

How did you mutate string concat? + to - too?

@simondel
Copy link

Yes. We don't look at the types of the left or right operand in binary expressions. We simply change the plus token into a minus token.

With JavaScript code, the mutant will actually get tested. With TypeScript it will first be ran though the TypeScript compiler which will (in most cases) cause an error. Mutants that cause a transpilation error are not tested and not counted in the score.

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

No branches or pull requests

2 participants