diff --git a/lib/mutant/mutator/node/begin.rb b/lib/mutant/mutator/node/begin.rb index 796f3188..d9d8b338 100644 --- a/lib/mutant/mutator/node/begin.rb +++ b/lib/mutant/mutator/node/begin.rb @@ -19,9 +19,7 @@ module Mutant # def dispatch Util::Array.each(children, self) do |children| - if children.length > 1 - emit_self(*children) - end + emit_child_subset(children) end children.each_with_index do |child, index| mutate_child(index) @@ -29,18 +27,22 @@ module Mutant end end - # Test if parent input is a send + # Emit child subset # - # @return [true] - # if parent input is a send node + # @param [Array] nodes # - # @return [false] - # otherwise + # @return [undefined] # # @api private # - def parent_send? - parent && parent.input.type == :send + def emit_child_subset(children) + case children.length + when 0 + when 1 + emit(children.first) + else + emit_self(*children) + end end end # Block diff --git a/lib/mutant/node_helpers.rb b/lib/mutant/node_helpers.rb index a16ad87c..06381972 100644 --- a/lib/mutant/node_helpers.rb +++ b/lib/mutant/node_helpers.rb @@ -18,13 +18,13 @@ module Mutant module_function :s NAN = - s(:begin, s(:send, s(:float, 0.0), :/, s(:args, s(:float, 0.0)))) + s(:send, s(:float, 0.0), :/, s(:args, s(:float, 0.0))) INFINITY = - s(:begin, s(:send, s(:float, 1.0), :/, s(:args, s(:float, 0.0)))) + s(:send, s(:float, 1.0), :/, s(:args, s(:float, 0.0))) NEW_OBJECT = s(:send, s(:const, s(:cbase), :Object), :new) NEGATIVE_INFINITY = - s(:begin, s(:send, s(:float, -1.0), :/, s(:args, s(:float, 0.0)))) + s(:send, s(:float, -1.0), :/, s(:args, s(:float, 0.0))) RAISE = s(:send, nil, :raise) diff --git a/mutant.gemspec b/mutant.gemspec index 99f71e7f..e10a772c 100644 --- a/mutant.gemspec +++ b/mutant.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |gem| gem.executables = %w[mutant] gem.add_runtime_dependency('parser', '~> 2.0.0.pre6') - gem.add_runtime_dependency('unparser', '~> 0.0.17') + gem.add_runtime_dependency('unparser', '~> 0.1.0') gem.add_runtime_dependency('ice_nine', '~> 0.8') gem.add_runtime_dependency('descendants_tracker', '~> 0.0.1') gem.add_runtime_dependency('adamantium', '~> 0.1.0') diff --git a/spec/shared/mutator_behavior.rb b/spec/shared/mutator_behavior.rb index 4b0793ba..9dade885 100644 --- a/spec/shared/mutator_behavior.rb +++ b/spec/shared/mutator_behavior.rb @@ -86,8 +86,9 @@ shared_examples_for 'a mutator' do if message.any? message = sprintf( - "Original:\n%s\n-----\n%s", + "Original:\n%s\n%s\n-----\n%s", generate(node), + node.inspect, message.join("\n-----\n") )