Mutare.Mutators.Conditional (mutare v0.1.2)

Copy Markdown View Source

Replace a boolean-valued expression with the constants true and false — the "remove conditionals" mutation. Forcing a decision to one side checks that both branches it guards are actually exercised by the suite.

Applies to the nodes that are guaranteed boolean-typed: the comparison and membership operators (>, >=, <, <=, ==, !=, ===, !==, in) and the logical connectives (and, or, &&, ||, not, !). Guard-safe — a bare boolean is legal in a when.

On by default. It overlaps the relational/logical swaps and roughly doubles the mutants at every condition, but the extra signal — proving each branch is actually exercised — is worth the volume. (On a short-circuit and/or whose left operand is itself a boolean op, the redundant whole-node constant is dropped, since forcing the left operand already covers it.)

Filterable variants — qualify a # mutare:ignore filter with :label to suppress just one kind (Mutare.Mutator.variants/0): true, false.

Summary

Functions

Whether op is one of the boolean-valued operators this mutator forces to true/false — the comparison/membership/logical connectives.

Functions

boolean_op?(op)

@spec boolean_op?(atom()) :: boolean()

Whether op is one of the boolean-valued operators this mutator forces to true/false — the comparison/membership/logical connectives.

Mutare.Mutators.ReturnValue and Mutare.Mutators.IfCondition reuse it to skip a boolean tail/condition rather than emit a mutant that would just duplicate this family's true/false; a custom mutator that forces values boolean can use it the same way, to avoid producing redundant mutants on a node Conditional already covers.