9e8b451933
* 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.
39 lines
762 B
Ruby
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
|