Muex.Equivalence (Muex v0.8.0)

View Source

Sound detection of equivalent mutants.

An equivalent mutant changes the source but not its observable behaviour, so no test can ever kill it. Counting equivalents as survivors deflates the mutation score and sends developers chasing phantom "weak tests", so they must be dropped before running.

Detection here is deliberately sound: a mutation is only reported as equivalent when it provably is. Missing some equivalents (false negatives) is acceptable — they merely cost a wasted test run. Wrongly dropping a killable mutant (a false positive) is not, since it would hide a real testing gap.

Two layers are consulted:

  1. AST-pattern rules for arithmetic/identity cases that are equivalent by construction (a + 0 vs a - 0, a * 1 vs a / 1, x <<< 0 vs x >>> 0).
  2. The per-mutator Muex.Mutator.equivalent?/1 hook and the explicit :equivalent flag, for cases a mutator declares itself.

Compiler-level equivalence (mutants that compile to identical BEAM) is handled separately by Muex.Tce.

Summary

Functions

Returns true when mutation is provably equivalent to the original code.

Rejects every equivalent mutation from mutations, preserving order.

Functions

equivalent?(mutation)

@spec equivalent?(map()) :: boolean()

Returns true when mutation is provably equivalent to the original code.

filter_equivalent(mutations)

@spec filter_equivalent([map()]) :: [map()]

Rejects every equivalent mutation from mutations, preserving order.