Class: Mutineer::Mutators::CollectionMethod
- Defined in:
- lib/mutineer/mutators/collection_method.rb
Overview
Collection / enumerable method-name mutator (Tier-2).
Swaps the method-name token of a call to its semantic opposite, one mutation per occurrence, exactly like the arithmetic/comparison operators.
Constant Summary collapse
- REPLACEMENTS =
Method-name swaps. All targets are core-Ruby Enumerable/Array methods so the mutant exercises real behaviour rather than always raising.
ponytail: include? -> exclude? was specced but skipped — exclude? is not core Ruby, so that mutant would always NoMethodError (a weak mutant).
{ map: "each", each: "map", all?: "any?", any?: "all?", first: "last", last: "first", min: "max", max: "min", select: "reject", reject: "select" }.freeze
Instance Method Summary collapse
-
#visit_call_node(node) ⇒ void
Visits call nodes and emits collection-method mutations.
Methods inherited from Base
Instance Method Details
#visit_call_node(node) ⇒ void
This method returns an undefined value.
Visits call nodes and emits collection-method mutations.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mutineer/mutators/collection_method.rb', line 29 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: :collection_method ) end super end |