Fix mutations on case without conditional
This commit is contained in:
parent
0758c16ba3
commit
9bafb2c395
3 changed files with 39 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
|
|
||||||
|
* Fix crash without conditionals
|
||||||
* Remove dependency to descendants tracker
|
* Remove dependency to descendants tracker
|
||||||
* Add mutation #== => #eql?, #equal?
|
* Add mutation #== => #eql?, #equal?
|
||||||
* Add mutation #eql? => #equal?
|
* Add mutation #eql? => #equal?
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def dispatch
|
def dispatch
|
||||||
emit_condition_mutations
|
emit_condition_mutations if condition
|
||||||
emit_when_mutations
|
emit_when_mutations
|
||||||
emit_else_mutations
|
emit_else_mutations
|
||||||
emit_nil
|
emit_nil
|
||||||
|
|
|
@ -9,6 +9,43 @@ describe Mutant::Mutator::Node::Case do
|
||||||
Mutant::Random.stub(hex_string: random_string)
|
Mutant::Random.stub(hex_string: random_string)
|
||||||
end
|
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
|
context 'with multiple when branches' do
|
||||||
let(:source) do
|
let(:source) do
|
||||||
<<-RUBY
|
<<-RUBY
|
||||||
|
|
Loading…
Add table
Reference in a new issue