Juggernaut.Schemata.Unit (Juggernaut v0.4.0)

Copy Markdown View Source

One file's metamutant (design notes §10.3, §10.4): its live mutants, how each is switched (Juggernaut.Schemata.Site), the lifted functions (Juggernaut.Schemata.Lift), the mutants taken out (with the reason) and the rendered source with its span map.

Each unit owns a fixed block of switches, base..base + size - 1, so taking mutants out of one file renumbers only that file and the others' rendered text stays the same (and Mix does not recompile them). Within the block, sites are numbered in source order and the mutants of one site consecutively, as Juggernaut.Peer.Switch.site/2 needs.

Inline sites whose ranges cross (rather than nest) cannot both be wrapped: the later one is lifted instead.

Summary

Functions

Takes the mutants with keys out of the unit, with reason.

The keys of the live mutants a list of switches names.

Poison isolation's step for the mutants with keys: an inline one is moved into a lifted copy of its function (its site cannot take a case, as inside a macro's argument, but the mutant alone may compile); a lifted one is taken out with reason.

Whether the unit's rendered source differs from the file as written.

The unit of file (its source and its mutants), with switches from base. Ignored mutants are not compiled and are left out.

Renders the unit: assigns switches and writes the metamutant source and its span map. A lifted mutant whose copy cannot be written is taken out first.

The live mutants with their switches (after render/1).

Takes every live mutant out with reason: the file is compiled as written.

Types

entry()

@type entry() :: %{
  mutant: Juggernaut.Mutant.t(),
  from: non_neg_integer(),
  to: non_neg_integer(),
  kind: :inline | {:lift, {module(), atom(), arity()}}
}

t()

@type t() :: %Juggernaut.Schemata.Unit{
  base: pos_integer(),
  bisect: Juggernaut.Schemata.Bisect.state() | nil,
  bisected: non_neg_integer(),
  excluded: %{
    required(String.t()) => %{mutant: Juggernaut.Mutant.t(), reason: String.t()}
  },
  file: String.t(),
  functions: %{
    required({module(), atom(), arity()}) => [
      Juggernaut.Mutator.ModuleScan.clause()
    ]
  },
  lifts: %{
    required({module(), atom(), arity()}) => Juggernaut.Schemata.Lift.t()
  },
  live: [entry()],
  rendered: binary() | nil,
  rounds: non_neg_integer(),
  sites: %{required(pos_integer()) => [pos_integer()]},
  size: non_neg_integer(),
  spans: [Juggernaut.Schemata.Text.span()],
  switches: %{required(String.t()) => pos_integer()},
  text: Juggernaut.Schemata.Text.t(),
  verbatim?: boolean()
}

Functions

exclude(unit, keys, reason)

@spec exclude(t(), [String.t()], String.t()) :: t()

Takes the mutants with keys out of the unit, with reason.

keys(unit, list)

@spec keys(t(), [pos_integer()]) :: [String.t()]

The keys of the live mutants a list of switches names.

lift_or_exclude(unit, keys, reason)

@spec lift_or_exclude(t(), [String.t()], String.t()) :: t()

Poison isolation's step for the mutants with keys: an inline one is moved into a lifted copy of its function (its site cannot take a case, as inside a macro's argument, but the mutant alone may compile); a lifted one is taken out with reason.

metamutant?(unit)

@spec metamutant?(t()) :: boolean()

Whether the unit's rendered source differs from the file as written.

new(file, source, mutants, base)

@spec new(String.t(), String.t(), [Juggernaut.Mutant.t()], pos_integer()) :: t()

The unit of file (its source and its mutants), with switches from base. Ignored mutants are not compiled and are left out.

render(unit)

@spec render(t()) :: t()

Renders the unit: assigns switches and writes the metamutant source and its span map. A lifted mutant whose copy cannot be written is taken out first.

switched(unit)

@spec switched(t()) :: [Juggernaut.Mutant.t()]

The live mutants with their switches (after render/1).

verbatim(unit, reason)

@spec verbatim(t(), String.t()) :: t()

Takes every live mutant out with reason: the file is compiled as written.