free_mutant/lib/mutant/mutator/block.rb

40 lines
762 B
Ruby
Raw Normal View History

module Mutant
class Mutator
class Block < Mutator
private
def mutants(generator)
mutate_elements(generator)
mutate_presence(generator)
end
def array
node.array
end
def dup_array
array.dup
end
def mutate_presence(generator)
array.each_index do |index|
array = dup_array
array.delete_at(index)
generator << new_self(array)
end
end
def mutate_elements(generator)
array.each_with_index do |child,index|
array = dup_array
Mutator.build(child).each do |mutation|
array[index]=mutation
generator << new_self(array)
end
end
end
end
end
end