Add mutator for self nodes

This commit is contained in:
Dan Kubb 2013-07-23 00:37:19 -07:00
parent 795be2c7e5
commit 23a84df277
5 changed files with 17 additions and 11 deletions

View file

@ -5,8 +5,6 @@ module Mutant
# Generic mutator
class Generic < self
handle(:self)
# These nodes still need a dedicated mutator,
# your contribution is that close!
handle(

View file

@ -3,10 +3,10 @@ module Mutant
class Node
module NamedValue
# Mutation emitter to handle value access nodes
# Mutation emitter to handle named value access nodes
class Access < Node
handle(:gvar, :cvar, :ivar, :lvar, :const)
handle(:gvar, :cvar, :ivar, :lvar, :const, :self)
private

View file

@ -74,4 +74,15 @@ describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
it_should_behave_like 'a mutator'
end
context 'self' do
let(:source) { 'self' }
let(:mutations) do
mutants = []
mutants << 'nil'
end
it_should_behave_like 'a mutator'
end
end

View file

@ -9,6 +9,7 @@ describe Mutant::Mutator, 'send' do
let(:mutations) do
mutations = []
mutations << 'foo ||= expression'
mutations << 'nil.foo ||= expression'
end
it_should_behave_like 'a mutator'
@ -74,6 +75,7 @@ describe Mutant::Mutator, 'send' do
mutations = []
mutations << 'foo'
mutations << 'self'
mutations << 'nil.foo'
end
it_should_behave_like 'a mutator'
@ -111,6 +113,7 @@ describe Mutant::Mutator, 'send' do
mutations = []
mutations << 'self.class'
mutations << 'self.foo'
mutations << 'nil.class.foo'
end
it_should_behave_like 'a mutator'
@ -142,6 +145,7 @@ describe Mutant::Mutator, 'send' do
mutations << 'foo(nil)'
mutations << 'nil'
mutations << 'self.foo(::Object.new)'
mutations << 'nil.foo(nil)'
end
it_should_behave_like 'a mutator'

View file

@ -1,7 +0,0 @@
require 'spec_helper'
describe Mutant::Mutator, 'self' do
let(:source) { 'self' }
it_should_behave_like 'a noop mutator'
end