Class: Mutineer::Mutators::Comparison
- Defined in:
- lib/mutineer/mutators/comparison.rb
Overview
Comparison / boundary operator: <->-<=, >->-=>, ==->!=, etc. The single highest-value Tier-1 family (spec §4) — exposes off-by-one and boundary gaps line coverage never catches. Rewrites the operator token (CallNode#message_loc), one mutation per occurrence.
Clean-room: implemented from the spec's operator table and public mutation-testing literature, not the mutant gem.
Constant Summary collapse
- REPLACEMENTS =
{ :< => "<=", :<= => "<", :> => ">=", :>= => ">", :== => "!=", :!= => "==" }.freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#visit_call_node(node) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mutineer/mutators/comparison.rb', line 19 def visit_call_node(node) replacement = REPLACEMENTS[node.name] loc = node. # receiver guard: reject any unary call accidentally named like an # operator; binary comparisons always have a receiver. 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 |