parent
380913d32d
commit
536d20bb9a
3 changed files with 22 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 18
|
||||
total_score: 1174
|
||||
total_score: 1181
|
||||
|
|
|
@ -103,6 +103,7 @@ module Mutant
|
|||
def emit_selector_specific_mutations
|
||||
emit_const_get_mutation
|
||||
emit_integer_mutation
|
||||
emit_dig_mutation
|
||||
end
|
||||
|
||||
# Emit selector mutations specific to top level constants
|
||||
|
@ -117,6 +118,24 @@ module Mutant
|
|||
.each(&method(:emit_selector))
|
||||
end
|
||||
|
||||
# Emit mutation for `#dig`
|
||||
#
|
||||
# - Mutates `foo.dig(a, b)` to `foo.fetch(a).dig(b)`
|
||||
# - Mutates `foo.dig(a)` to `foo.fetch(a)`
|
||||
#
|
||||
# @return [undefined]
|
||||
def emit_dig_mutation
|
||||
return if !selector.equal?(:dig) || arguments.none?
|
||||
|
||||
head, *tail = arguments
|
||||
|
||||
fetch_mutation = s(:send, receiver, :fetch, head)
|
||||
|
||||
return emit(fetch_mutation) if tail.empty?
|
||||
|
||||
emit(s(:send, fetch_mutation, :dig, *tail))
|
||||
end
|
||||
|
||||
# Emit mutation from `to_i` to `Integer(...)`
|
||||
#
|
||||
# @return [undefined]
|
||||
|
|
|
@ -255,6 +255,7 @@ Mutant::Meta::Example.add do
|
|||
source 'foo.dig(a, b)'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'foo.fetch(a).dig(b)'
|
||||
mutation 'foo'
|
||||
mutation 'self.dig(a, b)'
|
||||
mutation 'foo.dig(a)'
|
||||
|
@ -270,6 +271,7 @@ Mutant::Meta::Example.add do
|
|||
source 'foo.dig(a)'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'foo.fetch(a)'
|
||||
mutation 'foo'
|
||||
mutation 'self.dig(a)'
|
||||
mutation 'foo.dig(nil)'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue