Fix duplicate emit of neutral mutaiton on memoized instance methods

This commit is contained in:
Markus Schirp 2014-11-17 21:13:07 +00:00
parent 14e95080ed
commit 23bf4d2bd6
2 changed files with 14 additions and 1 deletions

View file

@ -85,7 +85,6 @@ module Mutant
# @api private
#
def generate_mutations(emitter)
emitter << neutral_mutation
Mutator.each(node) do |mutant|
emitter << Mutation::Evil.new(self, memoizer_node(mutant))
end

View file

@ -124,6 +124,20 @@ RSpec.describe Mutant::Subject::Method::Instance::Memoized do
it_should_behave_like 'a command method'
end
describe '#mutations' do
subject { object.mutations }
let(:expected) do
[
Mutant::Mutation::Neutral.new(object, s(:begin, s(:def, :foo, s(:args)), s(:send, nil, :memoize, s(:args, s(:sym, :foo))))),
Mutant::Mutation::Evil.new(object, s(:begin, s(:def, :foo, s(:args), s(:send, nil, :raise)), s(:send, nil, :memoize, s(:args, s(:sym, :foo))))),
Mutant::Mutation::Evil.new(object, s(:begin, s(:def, :foo, s(:args), nil), s(:send, nil, :memoize, s(:args, s(:sym, :foo))))),
]
end
it { should eql(expected) }
end
describe '#source' do
subject { object.source }