diff --git a/Changelog.md b/Changelog.md index 93cfe8bb..91636bed 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ # Master (unreleased) * Add mutation from `Hash#[]` to `Hash#key?` (#511) +* Add mutation from `Hash#fetch` to `Hash#key?` (#511) # v0.8.8 2015-xx-xx diff --git a/lib/mutant/mutator/node/send.rb b/lib/mutant/mutator/node/send.rb index 2506b3ba..2646b8dd 100644 --- a/lib/mutant/mutator/node/send.rb +++ b/lib/mutant/mutator/node/send.rb @@ -27,6 +27,7 @@ module Mutant to_a: %i[to_ary], to_h: %i[to_hash], at: %i[fetch], + fetch: %i[key?], :[] => %i[at fetch key?], :== => %i[eql? equal?], :>= => %i[> == eql? equal?], diff --git a/meta/send.rb b/meta/send.rb index 4e7a37ed..ba005e0b 100644 --- a/meta/send.rb +++ b/meta/send.rb @@ -359,6 +359,15 @@ Mutant::Meta::Example.add do mutation 'foo(nil)' end +Mutant::Meta::Example.add do + source 'self.fetch(nil)' + + singleton_mutations + mutation 'self.fetch' + mutation 'fetch(nil)' + mutation 'self.key?(nil)' +end + Unparser::Constants::KEYWORDS.each do |keyword| Mutant::Meta::Example.add do source "foo.#{keyword}(nil)"