Class: Evilution::Mutator::Operator::CollectionReplacement
- Inherits:
-
Base
- Object
- Prism::Visitor
- Base
- Evilution::Mutator::Operator::CollectionReplacement
- Defined in:
- lib/evilution/mutator/operator/collection_replacement.rb
Constant Summary collapse
- REPLACEMENTS =
{ map: [:each], each: [:map], select: [:reject], reject: [:select], flat_map: [:map], collect: [:each], sort: [:sort_by], sort_by: [:sort], find: [:detect], detect: [:find], any?: [:all?], all?: [:any?], count: [:length], length: [:count] }.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#call, #initialize, operator_name
Constructor Details
This class inherits a constructor from Evilution::Mutator::Base
Instance Method Details
#visit_call_node(node) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/evilution/mutator/operator/collection_replacement.rb', line 24 def visit_call_node(node) replacements = REPLACEMENTS[node.name] return super unless replacements loc = node. return super unless loc replacements.each do |replacement| add_mutation( offset: loc.start_offset, length: loc.length, replacement: replacement.to_s, node: node ) end super end |