2013-07-28 16:03:06 -07:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-12-06 20:44:26 +01:00
|
|
|
module Mutant
|
|
|
|
class Mutator
|
|
|
|
# Namespace for utility mutators
|
|
|
|
class Util < self
|
|
|
|
|
|
|
|
# Run ulitity mutator
|
|
|
|
#
|
2012-12-12 22:31:14 +01:00
|
|
|
# @param [Object] object
|
2013-06-24 22:10:40 +02:00
|
|
|
# @param [Object] parent
|
2012-12-12 22:31:14 +01:00
|
|
|
#
|
|
|
|
# @return [Enumerator<Object>]
|
|
|
|
# if no block given
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
# otherwise
|
2012-12-06 20:44:26 +01:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-06-24 22:10:40 +02:00
|
|
|
def self.each(object, parent, &block)
|
|
|
|
return to_enum(__method__, object, parent) unless block_given?
|
2012-12-06 20:44:26 +01:00
|
|
|
|
2013-06-24 22:10:40 +02:00
|
|
|
new(object, parent, block)
|
2012-12-06 20:44:26 +01:00
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2013-06-04 20:23:06 +02:00
|
|
|
private
|
|
|
|
|
2012-12-06 20:44:26 +01:00
|
|
|
# Test if mutation is new
|
|
|
|
#
|
|
|
|
# @param [Object] generated
|
|
|
|
#
|
|
|
|
# @return [true]
|
|
|
|
# if object is new
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# otherwise
|
|
|
|
#
|
2012-12-12 22:31:14 +01:00
|
|
|
# @api private
|
|
|
|
#
|
2012-12-06 20:44:26 +01:00
|
|
|
def new?(generated)
|
2012-12-06 21:30:28 +01:00
|
|
|
input != generated
|
2012-12-06 20:44:26 +01:00
|
|
|
end
|
2013-06-04 20:23:06 +02:00
|
|
|
|
|
|
|
end # Util
|
|
|
|
end # Mutator
|
|
|
|
end # Mutant
|