Fix mutations on case without conditional

This commit is contained in:
Markus Schirp 2014-04-06 21:59:12 +00:00
parent 0758c16ba3
commit 9bafb2c395
3 changed files with 39 additions and 1 deletions

View file

@ -2,6 +2,7 @@
Changes:
* Fix crash without conditionals
* Remove dependency to descendants tracker
* Add mutation #== => #eql?, #equal?
* Add mutation #eql? => #equal?

View file

@ -20,7 +20,7 @@ module Mutant
# @api private
#
def dispatch
emit_condition_mutations
emit_condition_mutations if condition
emit_when_mutations
emit_else_mutations
emit_nil

View file

@ -9,6 +9,43 @@ describe Mutant::Mutator::Node::Case do
Mutant::Random.stub(hex_string: random_string)
end
context 'without condition' do
let(:source) do
<<-RUBY
case
when true
else
end
RUBY
end
let(:mutations) do
mutations = []
mutations << 'nil'
mutations << <<-RUBY
case
when true
raise
else
end
RUBY
mutations << <<-RUBY
case
when false
else
end
RUBY
mutations << <<-RUBY
case
when nil
else
end
RUBY
end
it_should_behave_like 'a mutator'
end
context 'with multiple when branches' do
let(:source) do
<<-RUBY