free_mutant/lib/mutant/runner/mutation.rb

79 lines
1.4 KiB
Ruby
Raw Normal View History

# encoding: utf-8
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
#
2013-04-20 14:50:36 -04:00
# @return [Killer]
#
# @api private
#
attr_reader :killers
# Initialize object
#
2013-03-27 10:52:02 -04:00
# @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
2013-03-27 10:52:02 -04:00
# Test if mutation was handeled successfully
#
# @return [true]
# if successful
#
# @return [false]
# otherwise
#
# @api private
#
def success?
killers.any?(&:success?)
2013-03-27 10:52:02 -04:00
end
private
# Perform operation
#
# @return [undefined]
#
# @api private
#
def run
progress(mutation)
@killers = @tests.map do |test|
Mutant::Killer.new(
mutation: mutation,
test: test
)
end.map(&method(:visit))
progress(self)
end
2013-06-14 14:54:02 -04:00
end # Mutation
end # Runner
end # Mutant