free_mutant/lib/mutant/runner/subject.rb

86 lines
1.5 KiB
Ruby
Raw Normal View History

module Mutant
class Runner
# Subject specific runner
class Subject < self
include Equalizer.new(:config, :subject)
# Return subject
#
# @return [Subject]
#
# @api private
#
attr_reader :subject
register Mutant::Subject
# Initialize object
#
2013-03-27 10:52:02 -04:00
# @param [Config] config
# @param [Subject] subject
#
# @return [undefined]
#
# @api private
#
def initialize(config, subject)
@subject = subject
super(config)
end
2013-03-27 10:52:02 -04:00
# Return mutation runners
#
# @return [Enumerable<Runner::Mutation>]
#
# @api private
#
attr_reader :mutations
# Return failed mutations
#
# @return [Enumerable<Mutation>]
#
# @api private
#
def failed_mutations
mutations.reject(&:success?)
2013-03-27 10:52:02 -04:00
end
memoize :failed_mutations
# Test if subject was processed successful
#
2014-06-15 15:27:57 -04:00
# @return [Boolean]
2013-03-27 10:52:02 -04:00
#
# @api private
#
def success?
failed_mutations.empty?
end
# Return tests used to kill mutations on this subject
#
# @return [Enumerable<Test>]
#
# @api private
#
def tests
2014-06-28 18:54:28 -04:00
config.tests(subject)
end
memoize :tests
private
# Perform operation
#
# @return [undefined]
#
# @api private
#
def run
@mutations = visit_collection(subject.mutations, tests)
end
2013-06-14 14:54:02 -04:00
end # Subject
end # Runner
end # Mutant