Simplify explict_self_reciver mutation

This commit is contained in:
Markus Schirp 2012-08-01 14:38:12 +02:00
parent bb9809fa39
commit c168d33adc
4 changed files with 22 additions and 49 deletions

2
.rspec
View file

@ -1,2 +1,2 @@
--color
#--fail-fast
--fail-fast

1
TODO
View file

@ -21,3 +21,4 @@
* Use inheritable alias once (virtus,veritas,mapper,session, ...) support gem is born.
* Mutations on Rubinius::AST::Self?
* Support the numerous Rubinius::AST::SendWithArguments mutations.
* Fix rubinius to allow setting @vcall_style variable in Rubinius::AST::Send nodes.

View file

@ -3,8 +3,9 @@ module Mutant
# Abstract class for mutatiosn where messages are send
class Call < Mutator
private
handle(Rubinius::AST::Send)
private
# Return receiver AST node
#
@ -40,43 +41,29 @@ module Mutant
receiver.kind_of?(Rubinius::AST::Self)
end
class Send < Call
def emit_explicit_self_receiver
mutatee = dup_node
mutatee.privately = false
# TODO: Fix rubinius to allow this as an attr_accessor
mutatee.instance_variable_set(:@vcall_style,false)
emit_safe(mutatee)
end
handle(Rubinius::AST::Send)
private
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_explicit_self_receiver
end
# Emit an explicit self receiver if receiver is self
#
# Transforms a call on self with implict receiver into one with
# explcit receiver.
#
# foo => self.foo
#
# @return [undefined]
#
# @api private
#
def emit_explicit_self_receiver
emit_self(receiver,name,false,false)
end
# Emit mutations
#
# @return [undefined]
#
# @api private
#
def dispatch
emit_explicit_self_receiver
end
class SendWithArguments < Call
handle(Rubinius::AST::SendWithArguments)
private
private
# Emut mutations
#
@ -87,21 +74,6 @@ module Mutant
def dispatch
emit_explicit_self_receiver
end
# Emit an explicit self receiver if receiver is self
#
# Transforms a call on self with implict receiver into one with
# explcit receiver.
#
# foo => self.foo
#
# @return [undefined]
#
# @api private
#
def emit_explicit_self_receiver
emit_self(receiver,name,false,false)
end
end
end
end

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe Mutant::Mutator::Call, '.each' do
describe Mutant::Mutator, 'call' do
context 'send without arguments' do
context 'to self' do
@ -24,7 +24,7 @@ describe Mutant::Mutator::Call, '.each' do
end
end
pending 'send with arguments' do
context 'send with arguments' do
context 'to self' do
context 'implicit' do
let(:source) { 'foo(1)' }