Remove always dead mutations on rescue matchers
This commit is contained in:
parent
f8ac48c5f9
commit
9b12d9f3ba
3 changed files with 8 additions and 15 deletions
|
@ -8,7 +8,7 @@ module Mutant
|
|||
|
||||
handle(:resbody)
|
||||
|
||||
children :captures, :assignment, :block
|
||||
children :captures, :assignment, :body
|
||||
|
||||
private
|
||||
|
||||
|
@ -20,7 +20,7 @@ module Mutant
|
|||
#
|
||||
def dispatch
|
||||
emit_assignment(nil)
|
||||
emit_block_mutations if block
|
||||
emit_body_mutations if body
|
||||
mutate_captures
|
||||
end
|
||||
|
||||
|
@ -32,9 +32,8 @@ module Mutant
|
|||
#
|
||||
def mutate_captures
|
||||
return unless captures
|
||||
emit_captures(nil)
|
||||
Util::Array.each(captures.children, self) do |matchers|
|
||||
next if matchers.empty?
|
||||
next if matchers.empty? || matchers.any? { |node| node.type == :nil }
|
||||
emit_captures(s(:array, *matchers))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ private
|
|||
# @api private
|
||||
#
|
||||
def mutation_report
|
||||
message = ['Original:', original_node.inspect]
|
||||
message = ['Original-AST:', original_node.inspect, 'Original-Source:', Unparser.unparse(original_node)]
|
||||
if missing.any?
|
||||
message << 'Missing mutations:'
|
||||
message << missing.map(&method(:format_mutation)).join("\n-----\n")
|
||||
|
|
|
@ -10,31 +10,25 @@ describe Mutant::Mutator::Node::Generic, 'rescue' do
|
|||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'nil'
|
||||
# mutations << 'begin; rescue ExceptionA, ExceptionB => error; true; end'
|
||||
mutations << 'begin; rescue ExceptionA, ExceptionB; true; end'
|
||||
mutations << 'begin; rescue ExceptionA, ExceptionB => error; false; end'
|
||||
mutations << 'begin; rescue ExceptionA, ExceptionB => error; nil; end'
|
||||
mutations << 'begin; rescue ExceptionA, nil => error; true; end'
|
||||
mutations << 'begin; rescue ExceptionA => error; true; end'
|
||||
mutations << 'begin; rescue ExceptionB => error; true; end'
|
||||
mutations << 'begin; rescue nil, ExceptionB => error; true; end'
|
||||
mutations << 'begin; rescue => error; true; end'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
end
|
||||
|
||||
context 'single exception selector and assignment' do
|
||||
let(:source) { 'begin; rescue Exception => error; true; end' }
|
||||
let(:source) { 'begin; rescue SomeException => error; true; end' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'nil'
|
||||
mutations << 'begin; rescue Exception; true; end'
|
||||
mutations << 'begin; rescue Exception => error; false; end'
|
||||
mutations << 'begin; rescue Exception => error; nil; end'
|
||||
mutations << 'begin; rescue nil => error; true; end'
|
||||
mutations << 'begin; rescue => error; true; end'
|
||||
mutations << 'begin; rescue SomeException; true; end'
|
||||
mutations << 'begin; rescue SomeException => error; false; end'
|
||||
mutations << 'begin; rescue SomeException => error; nil; end'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
Loading…
Reference in a new issue