Class: Henitai::Operators::ArithmeticOperator
- Inherits:
-
Henitai::Operator
- Object
- Henitai::Operator
- Henitai::Operators::ArithmeticOperator
- Defined in:
- lib/henitai/operators/arithmetic_operator.rb
Overview
Replaces arithmetic operators with their mutation counterparts.
Constant Summary collapse
- NODE_TYPES =
[:send].freeze
- MUTATION_MATRIX =
{ :+ => :-, :- => :+, :* => :/, :/ => :*, :** => :*, :% => :* }.freeze
Constants inherited from Henitai::Operator
Henitai::Operator::FULL_SET, Henitai::Operator::LIGHT_SET
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Henitai::Operator
Class Method Details
.node_types ⇒ Object
19 20 21 |
# File 'lib/henitai/operators/arithmetic_operator.rb', line 19 def self.node_types NODE_TYPES end |
Instance Method Details
#mutate(node, subject:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/henitai/operators/arithmetic_operator.rb', line 23 def mutate(node, subject:) replacement = MUTATION_MATRIX[node.children[1]] return [] unless replacement [ build_mutant( subject:, original_node: node, mutated_node: mutated_node(node, replacement), description: "replaced #{node.children[1]} with #{replacement}" ) ] end |