Sha256: 918a46d07823dd65c8dccd4368c0fe2aac6599229884181da5a310f649b48d17

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

module Mutant
  class Runner
    # Mutation runner
    class Mutation < self
      include Equalizer.new(:config, :mutation, :tests)

      register Mutant::Mutation

      # Return mutation
      #
      # @return [Mutation]
      #
      # @api private
      #
      attr_reader :mutation

      # Return killers
      #
      # @return [Enumerable<Runner::Killer>]
      #
      # @api private
      #
      attr_reader :killers

      # Initialize object
      #
      # @param [Config] config
      # @param [Mutation] mutation
      # @param [Enumerable<Test>] tests
      #
      # @return [undefined]
      #
      # @api private
      #
      def initialize(config, mutation, tests)
        @mutation, @tests = mutation, tests
        super(config)
        @stop = config.fail_fast && !success?
      end

      # Test if mutation was handeled successfully
      #
      # @return [Boolean]
      #
      # @api private
      #
      def success?
        killers.any?(&:success?)
      end

    private

      # Perform operation
      #
      # @return [undefined]
      #
      # @api private
      #
      def run
        @killers = []

        killers = @tests.map do |test|
          Mutant::Killer.new(
            mutation: mutation,
            test:     test
          )
        end

        killers.each do |killer|
          runner = visit(killer)
          @killers << runner
          return if runner.mutation_dead?
        end
      end

    end # Mutation
  end # Runner
end # Mutant

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.5.24 lib/mutant/runner/mutation.rb
mutant-0.5.23 lib/mutant/runner/mutation.rb
mutant-0.5.22 lib/mutant/runner/mutation.rb