From ad162c2a428784c1835d5644aaff9438406f54fa Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Mon, 15 Jul 2013 22:25:09 +0200 Subject: [PATCH] Add dedicated splat mutator Closes #66 --- lib/mutant.rb | 1 + lib/mutant/mutator/node/generic.rb | 2 +- lib/mutant/mutator/node/splat.rb | 27 +++++++++++++++++++ .../mutant/mutator/node/send/mutation_spec.rb | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 lib/mutant/mutator/node/splat.rb diff --git a/lib/mutant.rb b/lib/mutant.rb index be1f83a1..8f1c6497 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -69,6 +69,7 @@ require 'mutant/mutator/node/return' require 'mutant/mutator/node/block' require 'mutant/mutator/node/if' require 'mutant/mutator/node/case' +require 'mutant/mutator/node/splat' require 'mutant/config' require 'mutant/loader' require 'mutant/context' diff --git a/lib/mutant/mutator/node/generic.rb b/lib/mutant/mutator/node/generic.rb index ee491fce..54b63fc1 100644 --- a/lib/mutant/mutator/node/generic.rb +++ b/lib/mutant/mutator/node/generic.rb @@ -12,7 +12,7 @@ module Mutant :zsuper, :not, :or, :and, :defined, :next, :break, :match, :gvar, :cvar, :ensure, :dstr, :dsym, :yield, :rescue, :redo, :defined?, - :lvar, :splat, :const, :blockarg, :block_pass, :op_asgn, :and_asgn, + :lvar, :const, :blockarg, :block_pass, :op_asgn, :and_asgn, :regopt, :ivar, :restarg, :casgn, :resbody, :retry, :arg_expr, :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :cbase, :empty, :alias, :for, :xstr, :back_ref, :nth_ref, :class, diff --git a/lib/mutant/mutator/node/splat.rb b/lib/mutant/mutator/node/splat.rb new file mode 100644 index 00000000..0b2369a5 --- /dev/null +++ b/lib/mutant/mutator/node/splat.rb @@ -0,0 +1,27 @@ +module Mutant + class Mutator + class Node + class Splat < self + + handle :splat + + children :expression + + private + + # Perform dispatch + # + # @return [undefined] + # + # @api private + # + def dispatch + emit_nil + emit_expression_mutations + emit(expression) + end + + end # Splat + end # Node + end # Mutator +end # Mutant diff --git a/spec/unit/mutant/mutator/node/send/mutation_spec.rb b/spec/unit/mutant/mutator/node/send/mutation_spec.rb index 908e0925..c53b3bad 100644 --- a/spec/unit/mutant/mutator/node/send/mutation_spec.rb +++ b/spec/unit/mutant/mutator/node/send/mutation_spec.rb @@ -31,6 +31,8 @@ describe Mutant::Mutator, 'send' do let(:mutations) do mutations = [] mutations << 'foo' + mutations << 'foo(nil)' + mutations << 'foo(bar)' end it_should_behave_like 'a mutator'