Class: ActiveMutator::Operators::ConditionForcing

Inherits:
Base
  • Object
show all
Defined in:
lib/active_mutator/operators/condition_forcing.rb

Constant Summary

Constants inherited from Base

Base::REGISTRY

Instance Method Summary collapse

Methods inherited from Base

all, inherited

Instance Method Details

#edits(node) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/active_mutator/operators/condition_forcing.rb', line 4

def edits(node)
  predicate =
    case node
    when Prism::IfNode, Prism::UnlessNode then node.predicate
    end
  return [] unless predicate

  %w[true false].reject { |lit| predicate.slice == lit }.map do |lit|
    edit(loc_range(predicate.location), lit, "force condition to `#{lit}`")
  end
end