Mutare.Mutators.ModeSwap (mutare v0.1.2)

Copy Markdown View Source

Replaces mode and unit atoms in supported standard-library calls. Each replacement is valid for that function and argument position.

Time and calendar units

String and encoding modes

Sort modes

For Enum.sort/2, Enum.sort_by/3, and List.keysort/3, the mutator exchanges :asc and :desc. It also changes the direction in {:asc | :desc, module} tuples. A literal module sorter, such as Enum.sort(values, Date), becomes {:desc, Date}. Variables and function sorters are not wrapped.

Keyword option modes

  • The case: option for Base.encode16/2, Base.decode16/2, Base.decode16!/2, and the corresponding Base32 and hex Base32 functions exchanges :upper and :lower. :mixed is unchanged.
  • The return: option for Regex.scan/3 and Regex.run/3 exchanges :index and :binary.
  • The on: option for Regex.split/3 changes :first and :all to :none; :none, :all_but_first, and :all_names change to :first. Lists of capture references are unchanged.

Ordered sets use adjacent replacements, so a position produces at most two mutants. Unrecognized atoms and values of other types are ignored.

This family is enabled by default. It matches aliased and piped calls and locates the option at its effective argument position. Because it rewrites the whole call, overlapping Mutare.Mutators.AtomLiteral and Mutare.Mutators.AliasLiteral leaf mutants are removed.