Add explicit mutator for and_asgn
This commit is contained in:
parent
3eef4f1173
commit
58e6910573
4 changed files with 34 additions and 2 deletions
|
@ -59,6 +59,7 @@ require 'mutant/mutator/node/literal/array'
|
|||
require 'mutant/mutator/node/literal/hash'
|
||||
require 'mutant/mutator/node/literal/regex'
|
||||
require 'mutant/mutator/node/literal/nil'
|
||||
require 'mutant/mutator/node/and_asgn'
|
||||
require 'mutant/mutator/node/argument'
|
||||
require 'mutant/mutator/node/arguments'
|
||||
require 'mutant/mutator/node/begin'
|
||||
|
|
30
lib/mutant/mutator/node/and_asgn.rb
Normal file
30
lib/mutant/mutator/node/and_asgn.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# encoding: utf-8
|
||||
|
||||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
|
||||
# AndAsgn mutator
|
||||
class AndAsgn < Generic
|
||||
|
||||
handle(:and_asgn)
|
||||
|
||||
children :left, :right
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
super
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # AndAsgn
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -12,7 +12,7 @@ module Mutant
|
|||
handle(
|
||||
:next, :break, :ensure,
|
||||
:dsym, :yield, :rescue, :redo, :defined?,
|
||||
:blockarg, :and_asgn,
|
||||
:blockarg,
|
||||
:regopt, :restarg, :resbody, :retry, :arg_expr,
|
||||
:kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
|
||||
:alias, :for, :xstr, :back_ref, :class,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Generic, 'and_asgn' do
|
||||
describe Mutant::Mutator::Node::AndAsgn, 'and_asgn' do
|
||||
let(:random_fixnum) { 5 }
|
||||
let(:random_string) { 'random' }
|
||||
|
||||
|
@ -16,6 +16,7 @@ describe Mutant::Mutator::Node::Generic, 'and_asgn' do
|
|||
mutations << 'a &&= -1'
|
||||
mutations << 'a &&= 2'
|
||||
mutations << 'a &&= 5'
|
||||
mutations << 'nil'
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
Loading…
Add table
Reference in a new issue