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