Class: Mutineer::Mutators::BooleanConnector
- Defined in:
- lib/mutineer/mutators/boolean_connector.rb
Overview
Boolean connector mutator.
Replaces symbolic and keyword connectors with their opposite form.
Constant Summary collapse
- REPLACEMENTS =
Token replacements for boolean connectors.
{ "&&" => "||", "||" => "&&", "and" => "or", "or" => "and" }.freeze
Instance Method Summary collapse
-
#emit(node) ⇒ void
private
Emits a connector mutation when the token is replaceable.
-
#visit_and_node(node) ⇒ void
Visits
andnodes. -
#visit_or_node(node) ⇒ void
Visits
ornodes.
Methods inherited from Base
Instance Method Details
#emit(node) ⇒ void (private)
This method returns an undefined value.
Emits a connector mutation when the token is replaceable.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mutineer/mutators/boolean_connector.rb', line 38 def emit(node) loc = node.operator_loc replacement = REPLACEMENTS[loc.slice] return unless replacement @mutations << Mutation.new( start_offset: loc.start_offset, end_offset: loc.end_offset, replacement: replacement, operator: :boolean_connector ) end |
#visit_and_node(node) ⇒ void
This method returns an undefined value.
Visits and nodes.
18 19 20 21 |
# File 'lib/mutineer/mutators/boolean_connector.rb', line 18 def visit_and_node(node) emit(node) super end |
#visit_or_node(node) ⇒ void
This method returns an undefined value.
Visits or nodes.
27 28 29 30 |
# File 'lib/mutineer/mutators/boolean_connector.rb', line 27 def visit_or_node(node) emit(node) super end |