
* I do not use 1.9.3 * Also keeping them in each file increases mental overhead (true it *can* be autoamted) * None of the files encodes NON ASCII chars. * I do not expect it makes any difference, since nobody programmatically will consume strings generated by mutant under the assumption they are UTF-8 encoded. * 1.9.3 Users have to deal with the encoding fuckup under ruby anyways.
89 lines
1.6 KiB
Ruby
89 lines
1.6 KiB
Ruby
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
|
|
#
|
|
# @param [Config] config
|
|
# @param [Subject] subject
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def initialize(config, subject)
|
|
@subject = subject
|
|
super(config)
|
|
end
|
|
|
|
# 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?)
|
|
end
|
|
memoize :failed_mutations
|
|
|
|
# Test if subject was processed successful
|
|
#
|
|
# @return [true]
|
|
# if successful
|
|
#
|
|
# @return [false]
|
|
# otherwise
|
|
#
|
|
# @api private
|
|
#
|
|
def success?
|
|
failed_mutations.empty?
|
|
end
|
|
|
|
# Return tests used to kill mutations on this subject
|
|
#
|
|
# @return [Enumerable<Test>]
|
|
#
|
|
# @api private
|
|
#
|
|
def tests
|
|
config.strategy.tests(subject)
|
|
end
|
|
memoize :tests
|
|
|
|
private
|
|
|
|
# Perform operation
|
|
#
|
|
# @return [undefined]
|
|
#
|
|
# @api private
|
|
#
|
|
def run
|
|
@mutations = visit_collection(subject.mutations, tests)
|
|
end
|
|
|
|
end # Subject
|
|
end # Runner
|
|
end # Mutant
|