lib/mutant/mutator/node/send.rb in mutant-0.8.11 vs lib/mutant/mutator/node/send.rb in mutant-0.8.12

- old
+ new

@@ -16,10 +16,11 @@ kind_of?: %i[instance_of?], is_a?: %i[instance_of?], reverse_each: %i[each], reverse_merge: %i[merge], map: %i[each], + flat_map: %i[map], sample: %i[first last], pop: %i[last], shift: %i[first], first: %i[last], last: %i[first], @@ -108,10 +109,12 @@ # @return [undefined] def emit_selector_specific_mutations emit_const_get_mutation emit_integer_mutation emit_dig_mutation + emit_double_negation_mutation + emit_lambda_mutation emit_drop_mutation end # Emit selector mutations specific to top level constants # @@ -123,10 +126,27 @@ .fetch(receiver.children.last, EMPTY_HASH) .fetch(selector, EMPTY_ARRAY) .each(&method(:emit_selector)) end + # Emit mutation from `!!foo` to `foo` + # + # @return [undefined] + def emit_double_negation_mutation + return unless selector.equal?(:!) && n_send?(receiver) + + negated = AST::Meta::Send.new(meta.receiver) + emit(negated.receiver) if negated.selector.equal?(:!) + end + + # Emit mutation from proc definition to lambda + # + # @return [undefined] + def emit_lambda_mutation + emit(s(:send, nil, :lambda)) if meta.proc? + end + # Emit mutation for `#dig` # # - Mutates `foo.dig(a, b)` to `foo.fetch(a).dig(b)` # - Mutates `foo.dig(a)` to `foo.fetch(a)` # @@ -230,7 +250,6 @@ end end # Send end # Node end # Mutator - end # Mutant