Sha256: dd92b1a559b530635a47a8d7add43eda69cdc97a514b8d5c26efa9df811dbaed
Contents?: true
Size: 1.25 KB
Versions: 17
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Mutant # Generator for mutations class Mutator REGISTRY = Registry.new(->(_) { Node::Generic }) include( Adamantium, Concord.new(:input, :parent), AbstractType, Procto ) # Lookup and invoke dedicated AST mutator # # @param node [Parser::AST::Node] # @param parent [nil,Mutant::Mutator::Node] # # @return [Set<Parser::AST::Node>] def self.mutate(node, parent = nil) self::REGISTRY.lookup(node.type).call(node, parent) end def self.handle(*types) types.each do |type| self::REGISTRY.register(type, self) end end private_class_method :handle # Return output # # @return [Set<Parser::AST::Node>] attr_reader :output alias_method :call, :output private def initialize(_input, _parent = nil) super @output = Set.new dispatch end def new?(object) !object.eql?(input) end abstract_method :dispatch private :dispatch def emit(object) return unless new?(object) output << object end def run(mutator) mutator.call(input).each(&method(:emit)) end def dup_input input.dup end end # Mutator end # Mutant
Version data entries
17 entries across 17 versions & 1 rubygems