
Logical operator mutators
logical_operators.RdReturns a ready-made list of operator() mutators covering short-circuit
(&&/||) and vectorised (&/|) logical operator swaps.
Value
A list of operator() mutators.
Details
Use on any file with compound conditions (if (a && b)). A surviving mutant
from this preset typically means test inputs are symmetric — both flags
TRUE or both FALSE. Adding a test with one flag TRUE and the other
FALSE exposes the difference between && and || and kills the mutant.
See also
vignette("mutators", package = "muttest") for the full operator table
and a worked example showing the symmetric-input pattern.
vignette("interpreting-results", package = "muttest") for how to
diagnose survivors and fix the underlying test weakness.
Examples
logical_operators()
#> [[1]]
#> Mutator: && → ||
#> Query: (binary_operator
#> lhs: (_) @lhs
#> operator: _ @operator
#> rhs: (_) @rhs
#> (#eq? @operator "&&")
#> )
#>
#> [[2]]
#> Mutator: || → &&
#> Query: (binary_operator
#> lhs: (_) @lhs
#> operator: _ @operator
#> rhs: (_) @rhs
#> (#eq? @operator "||")
#> )
#>
#> [[3]]
#> Mutator: & → |
#> Query: (binary_operator
#> lhs: (_) @lhs
#> operator: _ @operator
#> rhs: (_) @rhs
#> (#eq? @operator "&")
#> )
#>
#> [[4]]
#> Mutator: | → &
#> Query: (binary_operator
#> lhs: (_) @lhs
#> operator: _ @operator
#> rhs: (_) @rhs
#> (#eq? @operator "|")
#> )
#>
if (FALSE) { # \dontrun{
plan <- muttest_plan(
source_files = "R/access.R",
mutators = logical_operators()
)
muttest(plan, "tests/testthat")
} # }