Class: Evilution::Equivalent::Heuristic::VoidContext

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/equivalent/heuristic/void_context.rb

Constant Summary collapse

VOID_EQUIVALENT_PAIRS =

Method pairs where the only difference is the return value. In void context (return value unused), these are equivalent.

Set[
  Set[:each, :map],
  Set[:each, :reverse_each]
].freeze
MATCHING_OPERATORS =
Set["send_mutation", "collection_replacement"].freeze

Instance Method Summary collapse

Instance Method Details

#match?(mutation) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
# File 'lib/evilution/equivalent/heuristic/void_context.rb', line 15

def match?(mutation)
  return false unless MATCHING_OPERATORS.include?(mutation.operator_name)

  pair = extract_method_pair(mutation.diff)
  return false unless pair
  return false unless VOID_EQUIVALENT_PAIRS.include?(pair)

  void_context?(mutation)
end