Simplify explict_self_reciver mutation
This commit is contained in:
parent
bb9809fa39
commit
c168d33adc
4 changed files with 22 additions and 49 deletions
2
.rspec
2
.rspec
|
@ -1,2 +1,2 @@
|
|||
--color
|
||||
#--fail-fast
|
||||
--fail-fast
|
||||
|
|
1
TODO
1
TODO
|
@ -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.
|
||||
|
|
|
@ -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,11 +41,13 @@ module Mutant
|
|||
receiver.kind_of?(Rubinius::AST::Self)
|
||||
end
|
||||
|
||||
class Send < Call
|
||||
|
||||
handle(Rubinius::AST::Send)
|
||||
|
||||
private
|
||||
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
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
|
@ -56,22 +59,6 @@ module Mutant
|
|||
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
|
||||
|
||||
class SendWithArguments < Call
|
||||
|
||||
handle(Rubinius::AST::SendWithArguments)
|
||||
|
@ -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
|
||||
|
|
|
@ -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)' }
|
Loading…
Add table
Reference in a new issue