Muex.Tce (Muex v0.8.1)

View Source

Trivial Compiler Equivalence (TCE) for mutants.

Two pieces of source are compiler-equivalent when they compile to the same BEAM code. Such a mutant can never be killed — no test can distinguish it from the original — so it is an equivalent mutant and should be dropped.

This catches cases the AST-pattern rules in Muex.Equivalence cannot, e.g. deleting a @moduledoc/@doc or any change that the compiler erases, where the resulting function bytecode is byte-for-byte identical.

The comparison is sound: both modules are compiled under the same throwaway name, disassembled, their line annotations stripped, and the remaining instruction streams compared. Equivalence is reported only on an exact match; anything that fails to compile is treated as not provably equivalent so a real mutant is never hidden.

Summary

Functions

Returns true when the two quoted modules compile to identical BEAM code.

Like equivalent?/2, but the mutant is supplied as source text (as produced by the compiler when applying a mutation). Returns false if it does not parse.

Functions

equivalent?(module_ast_a, module_ast_b)

@spec equivalent?(Macro.t(), Macro.t()) :: boolean()

Returns true when the two quoted modules compile to identical BEAM code.

Returns false if they differ or if either fails to compile.

equivalent_source?(original_module_ast, mutated_source)

@spec equivalent_source?(Macro.t(), String.t()) :: boolean()

Like equivalent?/2, but the mutant is supplied as source text (as produced by the compiler when applying a mutation). Returns false if it does not parse.