Class: Mutineer::Mutators::NegationRemoval
- Defined in:
- lib/mutineer/mutators/negation_removal.rb
Overview
Negation-removal mutator (Tier-2).
Removes the ! or not of a negation, one mutation per occurrence:
!x becomes x and not x becomes x. The mutant survives when no
test depends on the negated value.
Instance Method Summary collapse
-
#emit(node) ⇒ void
private
Emits a mutation when the node is a prefix
!ornot. -
#visit_call_node(node) ⇒ void
Visits call nodes and emits negation-removal mutations.
Methods inherited from Base
Instance Method Details
#emit(node) ⇒ void (private)
This method returns an undefined value.
Emits a mutation when the node is a prefix ! or not.
The explicit form x.! is skipped: without its message, x. does
not parse.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mutineer/mutators/negation_removal.rb', line 31 def emit(node) return unless node.name == :! && node.call_operator_loc.nil? loc = node. @mutations << Mutation.new( start_offset: loc.start_offset, end_offset: loc.end_offset, replacement: "", operator: :negation_removal ) end |
#visit_call_node(node) ⇒ void
This method returns an undefined value.
Visits call nodes and emits negation-removal mutations.
17 18 19 20 |
# File 'lib/mutineer/mutators/negation_removal.rb', line 17 def visit_call_node(node) emit(node) super # nested negations (!!x) each get their own mutation end |