2012-11-21 18:10:50 -05:00
|
|
|
module Mutant
|
|
|
|
class Strategy
|
2012-12-10 18:17:19 -05:00
|
|
|
include AbstractType, Adamantium::Flat, Equalizer.new
|
|
|
|
|
|
|
|
# Return config
|
|
|
|
#
|
|
|
|
# @return [Config]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
attr_reader :config
|
|
|
|
|
|
|
|
# Initialize object
|
|
|
|
#
|
|
|
|
# @param [Config] config
|
|
|
|
#
|
|
|
|
# @return [undefined
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def initialize(config)
|
|
|
|
@config = config
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return output stream
|
|
|
|
#
|
|
|
|
# @return [IO]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def output_stream
|
|
|
|
config.reporter.output_stream
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return error stream
|
|
|
|
#
|
|
|
|
# @return [IO]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def error_stream
|
|
|
|
config.reporter.error_stream
|
|
|
|
end
|
2012-11-21 18:10:50 -05:00
|
|
|
|
|
|
|
# Kill mutation
|
|
|
|
#
|
2012-12-12 16:31:14 -05:00
|
|
|
# @param [Mutation] mutation
|
2012-11-21 18:10:50 -05:00
|
|
|
#
|
|
|
|
# @return [Killer]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-12-10 18:17:19 -05:00
|
|
|
def kill(mutation)
|
2012-11-21 18:10:50 -05:00
|
|
|
killer.new(self, mutation)
|
|
|
|
end
|
|
|
|
|
2012-12-07 10:55:53 -05:00
|
|
|
# Return killer
|
|
|
|
#
|
|
|
|
# @return [Class:Killer]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2012-12-10 18:17:19 -05:00
|
|
|
def killer
|
|
|
|
self.class::KILLER
|
2012-11-21 18:10:50 -05:00
|
|
|
end
|
|
|
|
|
2012-12-07 10:55:53 -05:00
|
|
|
# Static strategies
|
2012-11-21 21:00:36 -05:00
|
|
|
class Static < self
|
2012-12-10 18:17:19 -05:00
|
|
|
include Equalizer.new
|
2012-12-07 10:55:53 -05:00
|
|
|
|
|
|
|
# Always fail to kill strategy
|
2012-11-21 21:00:36 -05:00
|
|
|
class Fail < self
|
|
|
|
KILLER = Killer::Static::Fail
|
|
|
|
end
|
|
|
|
|
2012-12-07 10:55:53 -05:00
|
|
|
# Always succeed to kill strategy
|
2012-11-21 21:00:36 -05:00
|
|
|
class Success < self
|
|
|
|
KILLER = Killer::Static::Success
|
|
|
|
end
|
2012-11-21 18:10:50 -05:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|