Add Mutant::Mutator::Node::LocalVariable
This commit is contained in:
parent
06e16ee951
commit
72b7488809
4 changed files with 48 additions and 1 deletions
|
@ -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'
|
||||
|
|
|
@ -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,
|
||||
|
|
25
lib/mutant/mutator/node/lvar.rb
Normal file
25
lib/mutant/mutator/node/lvar.rb
Normal 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
|
21
spec/unit/mutant/mutator/node/lvar/mutation_spec.rb
Normal file
21
spec/unit/mutant/mutator/node/lvar/mutation_spec.rb
Normal 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
|
Loading…
Add table
Reference in a new issue