Skip to content

Commit

Permalink
Add a === b -> a.is_a?(b) mutation
Browse files Browse the repository at this point in the history
- Closes #689
  * NOTE: I have gone with `is_a?` over `kind_of?` because [this is more commonly used](https://github.com/rubocop-hq/ruby-style-guide#is-a-vs-kind-of)
  • Loading branch information
dgollahon committed Jan 2, 2021
1 parent 3e989f1 commit 8624245
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Unreleased


* [#1188](https://github.com/mbj/mutant/pull/1188)

Add `a === b` -> `a.is_a?(b)` mutation

* [#1189](https://github.com/mbj/mutant/pull/1189)

* Add mutation from `=~` -> `#match?`
Expand Down
1 change: 1 addition & 0 deletions lib/mutant/mutator/node/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Send < self
:< => %i[== eql? equal?],
:<= => %i[< == eql? equal?],
:== => %i[eql? equal?],
:=== => %i[is_a?],
:=~ => %i[match?],
:> => %i[== eql? equal?],
:>= => %i[> == eql? equal?],
Expand Down
16 changes: 15 additions & 1 deletion meta/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
mutation 'foo(n..-2)'
end

(Mutant::AST::Types::BINARY_METHOD_OPERATORS - %i[=~ <= >= < > == != eql?]).each do |operator|
(Mutant::AST::Types::BINARY_METHOD_OPERATORS - %i[=~ <= >= < > == === != eql?]).each do |operator|
Mutant::Meta::Example.add :send do
source "true #{operator} false"

Expand Down Expand Up @@ -729,3 +729,17 @@
mutation 'foo'
mutation 'foo(a__mutant__: nil)'
end

Mutant::Meta::Example.add :send do
source 'a === b'

singleton_mutations

mutation 'a'
mutation 'b'
mutation 'nil === b'
mutation 'self === b'
mutation 'a === nil'
mutation 'a === self'
mutation 'a.is_a?(b)'
end

0 comments on commit 8624245

Please sign in to comment.