Move named value access under consistent namespace
This commit is contained in:
parent
55c68a7b25
commit
c63f1d52af
10 changed files with 101 additions and 119 deletions
|
@ -54,17 +54,16 @@ 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/assignment'
|
||||
require 'mutant/mutator/node/argument'
|
||||
require 'mutant/mutator/node/arguments'
|
||||
require 'mutant/mutator/node/begin'
|
||||
require 'mutant/mutator/node/variable'
|
||||
require 'mutant/mutator/node/named_value/access'
|
||||
require 'mutant/mutator/node/named_value/assignment'
|
||||
require 'mutant/mutator/node/while'
|
||||
require 'mutant/mutator/node/super'
|
||||
require 'mutant/mutator/node/send'
|
||||
require 'mutant/mutator/node/send/binary'
|
||||
require 'mutant/mutator/node/when'
|
||||
require 'mutant/mutator/node/assignment'
|
||||
require 'mutant/mutator/node/define'
|
||||
require 'mutant/mutator/node/mlhs'
|
||||
require 'mutant/mutator/node/masgn'
|
||||
|
|
27
lib/mutant/mutator/node/named_value/access.rb
Normal file
27
lib/mutant/mutator/node/named_value/access.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
module NamedValue
|
||||
|
||||
# Mutation emitter to handle value access nodes
|
||||
class Access < Node
|
||||
|
||||
handle(:gvar, :cvar, :ivar, :lvar)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # Access
|
||||
end # NamedValue
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -1,11 +1,10 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
# Mutator base class for assignments
|
||||
class Assignment < self
|
||||
module NamedValue
|
||||
|
||||
# Mutator for variable assignment
|
||||
class Variable < self
|
||||
# Mutation emitter to handle value assignment nodes
|
||||
class Assignment < Node
|
||||
|
||||
children :name, :value
|
||||
|
||||
|
@ -44,8 +43,8 @@ module Mutant
|
|||
end
|
||||
end
|
||||
|
||||
end # Variable
|
||||
end # Assignment
|
||||
end # Assignment
|
||||
end # NamedValue
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -1,25 +0,0 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Node
|
||||
|
||||
# Mutation emitter to handle variable nodes
|
||||
class Variable < self
|
||||
|
||||
handle(:gvar, :cvar, :ivar, :lvar)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_nil
|
||||
end
|
||||
|
||||
end # Variable
|
||||
end # Node
|
||||
end # Mutator
|
||||
end # Mutant
|
|
@ -1,21 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator, 'cvar' 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
|
|
@ -1,21 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator, 'gvar' 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
|
|
@ -1,21 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator, 'ivar' 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
|
|
@ -1,21 +0,0 @@
|
|||
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
|
|
@ -0,0 +1,66 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
|
||||
|
||||
before do
|
||||
Mutant::Random.stub(:hex_string => :random)
|
||||
end
|
||||
|
||||
context 'global variable' do
|
||||
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
|
||||
|
||||
context 'class variable' do
|
||||
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
|
||||
end
|
||||
|
||||
context 'instance variable' do
|
||||
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
|
||||
|
||||
context 'local variable' do
|
||||
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
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Node::Assignment, 'mutations' do
|
||||
describe Mutant::Mutator::Node::NamedValue::Assignment, 'mutations' do
|
||||
|
||||
before do
|
||||
Mutant::Random.stub(:hex_string => :random)
|
Loading…
Reference in a new issue