Juggernaut.Schemata.Site (Juggernaut v0.4.0)

Copy Markdown View Source

Decides how each mutant is switched in its metamutant (design notes §10.3):

  • :inline - the site is an expression in runtime position: it becomes a case on the switch, with the original first and one branch per mutant;
  • :lift - anything else (a pattern, a guard, a dropped clause, a removed or narrowed pipe stage, a keyword key, an expression whose original binds a variable, an operand that a case cannot stand in for): the function is lifted and the mutant gets its own copy of the function's clauses (Juggernaut.Schemata.Lift);
  • {:excluded, reason} - the mutant cannot be switched at run time (it is in a macro, whose body runs at compile time). It is reported as a compile error with the reason, never run.

An inline site's original text must parse on its own in parentheses (as the case branch writes it; a bare keyword list does not) and bind no variable (bindings made inside a case branch do not reach the code after it); its replacement must parse the same way and not be empty. Its parent, found by following the mutant's path from the clause node with Sourceror.Zipper (literal wrappers skipped), must accept any expression in its place: not the right side of |>, the value of a comprehension's uniq:, nor the operand of &, ., @, ::, ^, when, unquote or an alias. Nor may any ancestor make it part of a pattern the walk calls runtime: the pattern of match?/2, or the head of a clause (a rescue spec such as e in [A, B]), though a cond condition is an expression.

Summary

Functions

How mutant, in clause (a Juggernaut.Mutator.ModuleScan clause), is switched.

Types

kind()

@type kind() :: :inline | :lift | {:excluded, String.t()}

Functions

classify(mutant, arg2)

@spec classify(Juggernaut.Mutant.t(), map() | nil) :: kind()

How mutant, in clause (a Juggernaut.Mutator.ModuleScan clause), is switched.