Add mutation of simple send without arguments
* Lets the block spec work again as 1.8 and 1.9 mode do not behave differend as with literals.
This commit is contained in:
parent
7f22299f5f
commit
fb7bb942a3
8 changed files with 60 additions and 70 deletions
|
@ -40,7 +40,6 @@ require 'mutant/mutator/literal/regex'
|
|||
require 'mutant/mutator/block'
|
||||
require 'mutant/mutator/self'
|
||||
require 'mutant/mutator/call'
|
||||
require 'mutant/mutator/call/send'
|
||||
require 'mutant/mutator/call/send_with_arguments'
|
||||
require 'mutant/loader'
|
||||
require 'mutant/context'
|
||||
|
|
|
@ -39,6 +39,38 @@ module Mutant
|
|||
def self?
|
||||
receiver.kind_of?(Rubinius::AST::Self)
|
||||
end
|
||||
|
||||
class Send < Call
|
||||
|
||||
handle(Rubinius::AST::Send)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_explicit_receiver
|
||||
end
|
||||
|
||||
# Emit a private vcall mutation
|
||||
#
|
||||
# Transforms a call on self with implict receiver into one with
|
||||
# explcit receiver.
|
||||
#
|
||||
# foo(1) => self.foo(1)
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_explicit_receiver
|
||||
emit_self(receiver,name,false,false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
module Mutant
|
||||
class Mutator
|
||||
class Call < Mutator
|
||||
# Mutator for Rubinius::AST::Send
|
||||
class Send < Call
|
||||
|
||||
handle(Rubinius::AST::Send)
|
||||
|
||||
private
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def dispatch
|
||||
emit_explicit_receiver
|
||||
end
|
||||
|
||||
# Emit a private vcall mutation
|
||||
#
|
||||
# Transforms a call on self with implict receiver into one with
|
||||
# explcit receiver.
|
||||
#
|
||||
# foo(1) => self.foo(1)
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def emit_explicit_receiver
|
||||
emit_self(receiver,name,false,true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -34,4 +34,8 @@ shared_examples_for 'a mutation enumerator method' do
|
|||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'a noop mutation enumerator method' do
|
||||
let(:mutations) { [] }
|
||||
|
||||
it_should_behave_like 'a mutation enumerator method'
|
||||
end
|
||||
|
|
20
spec/unit/mutant/mutator/block/class_methods/each_spec.rb
Normal file
20
spec/unit/mutant/mutator/block/class_methods/each_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Block, '.each' do
|
||||
# Two send operations
|
||||
let(:source) { "foo\nbar" }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
|
||||
# Mutation of each statement in block
|
||||
mutations << "foo\nself.bar"
|
||||
mutations << "self.foo\nbar"
|
||||
|
||||
## Remove statement in block
|
||||
mutations << [:block, 'foo'.to_sexp]
|
||||
mutations << [:block, 'bar'.to_sexp]
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutation enumerator method'
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Mutant::Mutator::Call, '.each' do
|
||||
pending 'send' do
|
||||
context 'send without arguments' do
|
||||
context 'to self' do
|
||||
|
||||
context 'implict' do
|
||||
|
@ -9,6 +9,7 @@ describe Mutant::Mutator::Call, '.each' do
|
|||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'self.foo' # without explict receiver (not send privately)
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutation enumerator method'
|
||||
|
@ -17,12 +18,7 @@ describe Mutant::Mutator::Call, '.each' do
|
|||
context 'explict' do
|
||||
let(:source) { 'self.foo' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
mutations << 'foo' # without explict receiver (send privately)
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutation enumerator method'
|
||||
it_should_behave_like 'a noop mutation enumerator method'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,23 +21,4 @@ describe Mutant::Mutator, '.each' do
|
|||
|
||||
it_should_behave_like 'a mutation enumerator method'
|
||||
end
|
||||
|
||||
pending 'block literal' do
|
||||
# Two send operations
|
||||
let(:source) { "self.foo\nself.bar" }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
|
||||
# Mutation of each statement in block
|
||||
mutations << "foo\nself.bar"
|
||||
mutations << "self.foo\nbar"
|
||||
|
||||
## Remove statement in block
|
||||
mutations << [:block, 'self.foo'.to_sexp]
|
||||
mutations << [:block, 'self.bar'.to_sexp]
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutation enumerator method'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,9 +3,5 @@ require 'spec_helper'
|
|||
describe Mutant::Mutator::Self, '.each' do
|
||||
let(:source) { 'self' }
|
||||
|
||||
let(:mutations) do
|
||||
mutations = []
|
||||
end
|
||||
|
||||
it_should_behave_like 'a mutation enumerator method'
|
||||
it_should_behave_like 'a noop mutation enumerator method'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue