Add explicit mutator for or_asgn
This commit is contained in:
parent
f714f8215f
commit
3eef4f1173
5 changed files with 35 additions and 2 deletions
|
@ -70,6 +70,7 @@ require 'mutant/mutator/node/named_value/constant_assignment'
|
|||
require 'mutant/mutator/node/named_value/variable_assignment'
|
||||
require 'mutant/mutator/node/noop'
|
||||
require 'mutant/mutator/node/op_asgn'
|
||||
require 'mutant/mutator/node/or_asgn'
|
||||
require 'mutant/mutator/node/while'
|
||||
require 'mutant/mutator/node/super'
|
||||
require 'mutant/mutator/node/zsuper'
|
||||
|
|
|
@ -16,7 +16,7 @@ module Mutant
|
|||
:regopt, :restarg, :resbody, :retry, :arg_expr,
|
||||
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
|
||||
:alias, :for, :xstr, :back_ref, :class,
|
||||
:sclass, :match_with_lvasgn, :match_current_line, :or_asgn, :kwbegin
|
||||
:sclass, :match_with_lvasgn, :match_current_line, :kwbegin
|
||||
)
|
||||
|
||||
private
|
||||
|
|
30
lib/mutant/mutator/node/or_asgn.rb
Normal file
30
lib/mutant/mutator/node/or_asgn.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# encoding: utf-8
|
||||
|
||||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
|
||||
# OrAsgn mutator
|
||||
class OrAsgn < Generic
|
||||
|
||||
handle(:or_asgn)
|
||||
|
||||
children :left, :right
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # OrAsgn
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Generic, 'or_asgn' do
|
||||
describe Mutant::Mutator::Node::OrAsgn, 'or_asgn' do
|
||||
let(:random_fixnum) { 5 }
|
||||
let(:random_string) { 'random' }
|
||||
|
||||
|
@ -16,6 +16,7 @@ describe Mutant::Mutator::Node::Generic, 'or_asgn' do
|
|||
mutations << 'a ||= -1'
|
||||
mutations << 'a ||= 2'
|
||||
mutations << 'a ||= 5'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
|
@ -41,6 +41,7 @@ describe Mutant::Mutator, 'send' do
|
|||
mutations = []
|
||||
mutations << 'foo ||= expression'
|
||||
mutations << 'nil.foo ||= expression'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutator'
|
||||
|
|
Loading…
Add table
Reference in a new issue