2018-09-12 14:21:24 +00:00
|
|
|
# frozen_string_literal: true
|
2018-09-12 13:15:43 +00:00
|
|
|
|
2012-12-29 20:12:48 +01:00
|
|
|
module Mutant
|
|
|
|
class Mutator
|
|
|
|
class Util
|
|
|
|
|
|
|
|
# Mutators that mutates an array of inputs
|
|
|
|
class Array < self
|
|
|
|
|
2013-01-04 22:16:03 +01:00
|
|
|
# Element presence mutator
|
2012-12-29 20:12:48 +01:00
|
|
|
class Presence < Util
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Emit element presence mutations
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
def dispatch
|
|
|
|
input.each_index do |index|
|
|
|
|
dup = dup_input
|
|
|
|
dup.delete_at(index)
|
|
|
|
emit(dup)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-14 20:54:02 +02:00
|
|
|
end # Presence
|
2012-12-29 20:12:48 +01:00
|
|
|
|
2013-01-04 22:16:03 +01:00
|
|
|
# Array element mutator
|
2012-12-29 20:12:48 +01:00
|
|
|
class Element < Util
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Emit mutations
|
2013-04-17 20:31:21 -07:00
|
|
|
#
|
2012-12-29 20:12:48 +01:00
|
|
|
# @return [undefined]
|
|
|
|
def dispatch
|
|
|
|
input.each_with_index do |element, index|
|
2016-05-05 23:36:46 -07:00
|
|
|
Mutator.mutate(element).each do |mutation|
|
2013-06-04 22:17:01 +02:00
|
|
|
dup = dup_input
|
2013-07-27 21:14:41 +02:00
|
|
|
dup[index] = mutation
|
2012-12-29 20:12:48 +01:00
|
|
|
emit(dup)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-14 20:54:02 +02:00
|
|
|
end # Element
|
2013-06-04 22:17:01 +02:00
|
|
|
end # Array
|
2016-04-10 14:33:47 -07:00
|
|
|
end # Util
|
|
|
|
end # Mutator
|
|
|
|
end # Mutant
|