Muex. Equivalence
(Muex v0.8.1)
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:
- AST-pattern rules for arithmetic/identity cases that are equivalent by
construction (
a + 0vsa - 0,a * 1vsa / 1,x <<< 0vsx >>> 0). - The per-mutator
Muex.Mutator.equivalent?/1hook and the explicit:equivalentflag, 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.