Don't emit invalid MLHS child mutation

This commit is contained in:
Lars Gierth 2013-12-07 01:49:18 +01:00
parent 30c094b002
commit 21128f74cf
2 changed files with 23 additions and 1 deletions

View file

@ -19,7 +19,7 @@ module Mutant
def dispatch
children.each_index do |index|
mutate_child(index)
delete_child(index)
delete_child(index) if children.length > 1
end
end

View file

@ -70,4 +70,26 @@ describe Mutant::Mutator, 'block' do
it_should_behave_like 'a mutator'
end
context 'with mini block pattern arg' do
before do
Mutant::Random.stub(hex_string: 'random')
end
let(:source) { 'foo { |(a)| }' }
let(:mutations) do
mutations = []
mutations << 'foo { || }'
mutations << 'foo { |a| }'
mutations << 'foo { |(a)| raise }'
mutations << 'foo { |(srandom)| }'
mutations << 'foo'
mutations << 'nil'
end
it_should_behave_like 'a mutator'
end
end