Sha256: ff3e87d70cf5541b23e79cf22167a8831bd1e2631b14f5892c81c0d9e47cab30

Contents?: true

Size: 1.32 KB

Versions: 13

Compression:

Stored size: 1.32 KB

Contents

# encoding: utf-8

module Mutant

  # Abstract base class for killing strategies
  class Strategy
    include AbstractType, Adamantium::Flat, Equalizer.new

    REGISTRY = {}

    # Lookup strategy for name
    #
    # @param [String] name
    #
    # @return [Strategy]
    #   if found
    #
    # @api private
    #
    def self.lookup(name)
      REGISTRY.fetch(name)
    end

    # Register strategy
    #
    # @param [String] name
    #
    # @return [undefined]
    #
    # @api private
    #
    def self.register(name)
      REGISTRY[name] = self
    end
    private_class_method :register

    # Perform strategy setup
    #
    # @return [self]
    #
    # @api private
    #
    def setup
      self
    end

    # Perform strategy teardown
    #
    # @return [self]
    #
    # @api private
    #
    def teardown
      self
    end

    # Kill mutation
    #
    # @param [Mutation] mutation
    #
    # @return [Killer]
    #
    # @api private
    #
    def kill(mutation)
      killer.new(self, mutation)
    end

  private

    # Return killer
    #
    # @return [Class:Killer]
    #
    # @api private
    #
    def killer
      self.class::KILLER
    end

    # Null strategy that never kills a mutation
    class Null < self

      register 'null'

      KILLER = Killer::Null

    end # Null

  end # Strategy

end # Mutant

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mutant-0.5.12 lib/mutant/strategy.rb
mutant-0.5.11 lib/mutant/strategy.rb
mutant-0.5.10 lib/mutant/strategy.rb
mutant-0.5.9 lib/mutant/strategy.rb
mutant-0.5.8 lib/mutant/strategy.rb
mutant-0.5.7 lib/mutant/strategy.rb
mutant-0.5.6 lib/mutant/strategy.rb
mutant-0.5.5 lib/mutant/strategy.rb
mutant-0.5.4 lib/mutant/strategy.rb
mutant-0.5.3 lib/mutant/strategy.rb
mutant-0.5.2 lib/mutant/strategy.rb
mutant-0.5.1 lib/mutant/strategy.rb
mutant-0.5.0 lib/mutant/strategy.rb