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

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

VOID_EQUIVALENT_PAIRS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

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 =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Set["send_mutation", "collection_replacement"].freeze

Instance Method Summary collapse

Instance Method Details

#match?(mutation) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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