diff --git a/config/flay.yml b/config/flay.yml index 969a6f58..90f85a23 100644 --- a/config/flay.yml +++ b/config/flay.yml @@ -1,3 +1,3 @@ --- threshold: 16 -total_score: 1166 +total_score: 1171 diff --git a/lib/mutant/mutator/node/send.rb b/lib/mutant/mutator/node/send.rb index 6829e10a..7d48a1db 100644 --- a/lib/mutant/mutator/node/send.rb +++ b/lib/mutant/mutator/node/send.rb @@ -105,6 +105,7 @@ module Mutant emit_const_get_mutation emit_integer_mutation emit_dig_mutation + emit_drop_mutation end # Emit selector mutations specific to top level constants @@ -137,6 +138,19 @@ module Mutant emit(s(:send, fetch_mutation, :dig, *tail)) end + # Emit mutation `foo[n..-1]` -> `foo.drop(n)` + # + # @return [undefined] + def emit_drop_mutation + return if !selector.equal?(:[]) || !arguments.one? || !n_irange?(arguments.first) + + start, ending = *arguments.first + + return unless ending.eql?(s(:int, -1)) + + emit(s(:send, receiver, :drop, start)) + end + # Emit mutation from `to_i` to `Integer(...)` # # @return [undefined] diff --git a/meta/send.rb b/meta/send.rb index 6691d9e8..5332471d 100644 --- a/meta/send.rb +++ b/meta/send.rb @@ -597,6 +597,7 @@ Mutant::Meta::Example.add :send do mutation 'foo[n..(1.0 / 0.0)]' mutation 'foo[n..(0.0 / 0.0)]' mutation 'foo[(0.0 / 0.0)..-1]' + mutation 'foo.drop(n)' end Mutant::Meta::Example.add :send do