free_mutant/lib/mutant/mutator/block.rb
Markus Schirp 9e8b451933 Add mutation for some literals
* This is in progress code. The plan is to support all literals before
  beginning to cleanup and dedup the mutation generation. Have to
  understand the AST and the possible mutations more in depth before
  making structural decisions here.
2012-07-27 22:39:31 +02:00

39 lines
762 B
Ruby

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