Add Mutant::Mutator::Node::LocalVariable

This commit is contained in:
Dan Kubb 2013-07-22 00:33:54 -07:00
parent 06e16ee951
commit 72b7488809
4 changed files with 48 additions and 1 deletions

View file

@ -58,6 +58,7 @@ require 'mutant/mutator/node/assignment'
require 'mutant/mutator/node/argument'
require 'mutant/mutator/node/arguments'
require 'mutant/mutator/node/begin'
require 'mutant/mutator/node/lvar'
require 'mutant/mutator/node/while'
require 'mutant/mutator/node/super'
require 'mutant/mutator/node/send'

View file

@ -13,7 +13,7 @@ module Mutant
:zsuper, :not, :or, :and, :defined,
:next, :break, :match, :gvar, :cvar, :ensure,
:dstr, :dsym, :yield, :rescue, :redo, :defined?,
:lvar, :const, :blockarg, :block_pass, :op_asgn, :and_asgn,
: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,

View file

@ -0,0 +1,25 @@
module Mutant
class Mutator
class Node
# Mutation emitter to handle local variable nodes
class LocalVariable < self
handle(:lvar)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_nil
end
end # LocalVariable
end # Node
end # Mutator
end # Mutant

View file

@ -0,0 +1,21 @@
require 'spec_helper'
describe Mutant::Mutator, 'lvar' do
before do
Mutant::Random.stub(:hex_string => 'random')
end
let(:source) { 'a = nil; a' }
let(:mutations) do
mutants = []
mutants << 'a = nil; nil'
mutants << 'a = nil'
mutants << 'a'
mutants << 'a = ::Object.new; a'
mutants << 'srandom = nil; a'
end
it_should_behave_like 'a mutator'
end