Class: Mutineer::Mutators::Arithmetic
- Defined in:
- lib/mutineer/mutators/arithmetic.rb
Overview
Arithmetic operator mutator.
One mutation per occurrence, rewriting the operator token.
Constant Summary collapse
- REPLACEMENTS =
Token replacements for arithmetic operators.
{ :+ => "-", :- => "+", :* => "/", :/ => "*", :% => "*", :** => "*" }.freeze
Instance Method Summary collapse
-
#visit_call_node(node) ⇒ void
Visits call nodes and emits arithmetic mutations.
Methods inherited from Base
Instance Method Details
#visit_call_node(node) ⇒ void
This method returns an undefined value.
Visits call nodes and emits arithmetic mutations.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mutineer/mutators/arithmetic.rb', line 20 def visit_call_node(node) replacement = REPLACEMENTS[node.name] loc = node. if replacement && loc @mutations << Mutation.new( start_offset: loc.start_offset, end_offset: loc.end_offset, replacement: replacement, operator: :arithmetic ) end super # nested calls (e.g. a + (b * c)) each get their own mutation end |