Class: Evilution::Equivalent::Heuristic::AliasSwap
- Inherits:
-
Object
- Object
- Evilution::Equivalent::Heuristic::AliasSwap
- Defined in:
- lib/evilution/equivalent/heuristic/alias_swap.rb
Constant Summary collapse
- ALIAS_PAIRS =
Set[ Set[:detect, :find], Set[:length, :size], Set[:collect, :map], Set[:count, :length], Set[:count, :size] ].freeze
- MATCHING_OPERATORS =
Set["send_mutation", "collection_replacement"].freeze
Instance Method Summary collapse
Instance Method Details
#match?(mutation) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/evilution/equivalent/heuristic/alias_swap.rb', line 16 def match?(mutation) return false unless MATCHING_OPERATORS.include?(mutation.operator_name) diff = mutation.diff removed = extract_method(diff, "- ") added = extract_method(diff, "+ ") return false unless removed && added pair = Set[removed.to_sym, added.to_sym] ALIAS_PAIRS.include?(pair) end |