MutagenEx.Mutators.ResultTuple (mutagen_ex v0.2.0)

Copy Markdown View Source

Flips {:ok, x} and {:error, x} tagged tuples.

Per mutagen.mutators catalog entry 8.

Two-element tagged tuples in Elixir source parse as the 2-tuple literal {:ok, x} — i.e. an Elixir tuple value, NOT a {form, meta, args} AST node. We match on that 2-element tuple shape directly.

Swap

  • {:ok, x} → {:error, x}
  • {:error, x} → {:ok, x}

Fully symmetric: mutate(mutate(node)) == node.

Validation

  • :structurally_invalid — not a {:ok, _} or {:error, _} 2-tuple.