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

[bug] Mutation conditionals-negation only works partially with conditionals-boundary disabled #225

Open
hknutzen opened this issue Jan 21, 2024 · 5 comments
Assignees
Labels
c/bug Category: A issue or PR related to a bug

Comments

@hknutzen
Copy link
Contributor

🐞Bug Report

Bug Description

The mutation conditionals-negation is only applied to "==" and "!=" but not to ">", "<=", "<", ">=" if mutation conditionals-boundary is disabled.

To Reproduce

Steps to reproduce the behavior:

With this example code

package f

import "fmt"

func f(a, b int) string {
	return fmt.Sprintf("%v %v %v %v %v %v",
		a == b,
		a != b,
		a < b,
		a <= b,
		a > b,
		a >= b,
	)
}

run
gremlins run --dry-run --conditionals_boundary=false --workers 1
Output is

 NOT COVERED CONDITIONALS_NEGATION at f.go:7:5
 NOT COVERED CONDITIONALS_NEGATION at f.go:8:5

But with
gremlins run --dry-run --workers 1
we get

 NOT COVERED CONDITIONALS_NEGATION at f.go:7:5
 NOT COVERED CONDITIONALS_NEGATION at f.go:8:5
 NOT COVERED CONDITIONALS_BOUNDARY at f.go:9:5
 NOT COVERED CONDITIONALS_NEGATION at f.go:9:5
 NOT COVERED CONDITIONALS_BOUNDARY at f.go:10:5
 NOT COVERED CONDITIONALS_NEGATION at f.go:10:5
 NOT COVERED CONDITIONALS_BOUNDARY at f.go:11:5
 NOT COVERED CONDITIONALS_NEGATION at f.go:11:5
 NOT COVERED CONDITIONALS_BOUNDARY at f.go:12:5
 NOT COVERED CONDITIONALS_NEGATION at f.go:12:5

Found behaviour

Only two from six mutations of conditionals-negation are applied.

Expected behaviour

All six mutations should be applied, even if mutation conditionals-boundary is disabled.

Operating System

@hknutzen hknutzen added the c/bug Category: A issue or PR related to a bug label Jan 21, 2024
@hknutzen
Copy link
Contributor Author

I found this bug, when comparing mutation testing results of Gremlins and Ooze.
Mutation "conditionals-negation" of Gremlins is equivalent to "comparisoninvert" of Ooze.

@rusinikita
Copy link
Contributor

rusinikita commented Feb 14, 2024

Hi! I don't understand why different behaviour expected.

That's different mutators. One for ==, != other for >, <, =>, <=

https://gremlins.dev/latest/usage/mutations/conditionals_boundary/
https://gremlins.dev/latest/usage/mutations/conditionals_negation/

Conditionals negation inverts the conditional direction, which means a == will become a !=

I guess it's just a bug in documentation page and can be easily fixed in md. What do you think?

@hknutzen
Copy link
Contributor Author

The term a > b is mutated to

  1. a >= b by conditionals boundary
  2. a <= b by conditionals negation

The bug is, that the 2. mutation is only applied if both mutators are activated.

My example shows that both mutators are applicable to a > b:

 NOT COVERED CONDITIONALS_BOUNDARY at f.go:11:5
 NOT COVERED CONDITIONALS_NEGATION at f.go:11:5

@rusinikita
Copy link
Contributor

Yep! Got it. I'll find a fix

@rusinikita
Copy link
Contributor

rusinikita commented Feb 15, 2024

Here should be continue instead of return.

https://github.com/go-gremlins/gremlins/blob/main/internal/engine/engine.go#L142

Because of that, it checks for CONDITIONALS_BOUNDARY and returns. So, it do not checks for CONDITIONALS_NEGATION.

Do you want to make PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/bug Category: A issue or PR related to a bug
Projects
None yet
Development

No branches or pull requests

3 participants