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