class Crispr::Mutations::Comparison

This includes flipping equality and inequality, and reversing inequality directions.
Defines mutations for comparison operators.

def mutations_for(node)

Returns:
  • (Array) - mutated nodes

Parameters:
  • node (Parser::AST::Node) -- the AST node to inspect
def mutations_for(node)
  return [] unless node.type == :send
  return [] unless COMPARISON_FLIPS.key?(node.children[1])
  flipped_operator = COMPARISON_FLIPS[node.children[1]]
  mutated_node = node.updated(nil, [node.children[0], flipped_operator, *node.children[2..]])
  [mutated_node]
end