Prefer Object#is_a? over #kind_of?
This commit is contained in:
parent
67573c2337
commit
c7de9a24fb
6 changed files with 18 additions and 5 deletions
|
@ -115,7 +115,7 @@ module Mutant
|
|||
def expression(scope)
|
||||
name = scope_name(scope) or return
|
||||
|
||||
unless name.kind_of?(String)
|
||||
unless name.is_a?(String)
|
||||
warn("#{scope.class}#name from: #{scope.inspect} did not return a String or nil. Fix your lib to support normal ruby semantics!")
|
||||
return
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ module Mutant
|
|||
emit_singletons unless parent_node && n_const?(parent_node)
|
||||
emit_type(nil, *children.drop(1))
|
||||
children.each_with_index do |child, index|
|
||||
mutate_child(index) if child.kind_of?(Parser::AST::Node)
|
||||
mutate_child(index) if child.is_a?(Parser::AST::Node)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ module Mutant
|
|||
#
|
||||
def dispatch
|
||||
children.each_with_index do |child, index|
|
||||
mutate_child(index) if child.kind_of?(Parser::AST::Node)
|
||||
mutate_child(index) if child.is_a?(Parser::AST::Node)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def self.assert_valid_type(type)
|
||||
unless AST::Types::ALL.include?(type) || type.kind_of?(Class)
|
||||
unless AST::Types::ALL.include?(type) || type.is_a?(Class)
|
||||
raise InvalidTypeError, "invalid type registration: #{type}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -103,7 +103,7 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def finish(mutation, index, result)
|
||||
return unless result.kind_of?(Mutant::Result::Mutation)
|
||||
return unless result.is_a?(Mutant::Result::Mutation)
|
||||
|
||||
test_results = result.test_results.zip(mutation.subject.tests).map do |test_result, test|
|
||||
test_result.update(test: test, mutation: mutation) if test_result
|
||||
|
|
13
meta/send.rb
13
meta/send.rb
|
@ -145,6 +145,19 @@ Mutant::Meta::Example.add do
|
|||
mutation 'foo.instance_of?(bar)'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
source 'foo.is_a?(bar)'
|
||||
|
||||
singleton_mutations
|
||||
mutation 'foo'
|
||||
mutation 'bar'
|
||||
mutation 'foo.is_a?'
|
||||
mutation 'foo.is_a?(nil)'
|
||||
mutation 'foo.is_a?(self)'
|
||||
mutation 'self.is_a?(bar)'
|
||||
mutation 'foo.instance_of?(bar)'
|
||||
end
|
||||
|
||||
Mutant::Meta::Example.add do
|
||||
source 'foo.kind_of?(bar)'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue