parent
cf26c582c1
commit
f00ecf78fb
5 changed files with 49 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
* Add mutation from `Date.parse` to more strict parsing methods #448
|
||||
* Add mutation from `foo.to_i` to `Integer(foo)` #455
|
||||
* Add mutation from `@foo` to `foo` #454
|
||||
|
||||
# v0.8.5 2015-09-11
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 18
|
||||
total_score: 1244
|
||||
total_score: 1253
|
||||
|
|
|
@ -6,7 +6,7 @@ module Mutant
|
|||
# Mutation emitter to handle named value access nodes
|
||||
class Access < Node
|
||||
|
||||
handle(:gvar, :cvar, :ivar, :lvar, :self)
|
||||
handle(:gvar, :cvar, :lvar, :self)
|
||||
|
||||
private
|
||||
|
||||
|
@ -19,6 +19,45 @@ module Mutant
|
|||
emit_singletons
|
||||
end
|
||||
|
||||
# Named value access emitter for instance variables
|
||||
class Ivar < Access
|
||||
NAME_RANGE = (1..-1).freeze
|
||||
|
||||
handle(:ivar)
|
||||
|
||||
children :name
|
||||
|
||||
# Emit mutations
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
def dispatch
|
||||
emit_attribute_read
|
||||
super()
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Emit instance variable as attribute send
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
def emit_attribute_read
|
||||
emit(s(:send, nil, attribute_name))
|
||||
end
|
||||
|
||||
# Variable name without leading '@'
|
||||
#
|
||||
# @return [Symbol]
|
||||
#
|
||||
# @api private
|
||||
def attribute_name
|
||||
name.slice(NAME_RANGE).to_sym
|
||||
end
|
||||
end
|
||||
|
||||
end # Access
|
||||
end # NamedValue
|
||||
end # Node
|
||||
|
|
6
meta/ivar.rb
Normal file
6
meta/ivar.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
Mutant::Meta::Example.add do
|
||||
source '@foo'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'foo'
|
||||
end
|
|
@ -2,6 +2,7 @@ Mutant::Meta::Example.add do
|
|||
source '@a.b += 1'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'a.b += 1'
|
||||
mutation '@a.b += -1'
|
||||
mutation '@a.b += 2'
|
||||
mutation '@a.b += 0'
|
||||
|
|
Loading…
Reference in a new issue