Prefer Object#is_a? over #kind_of?

This commit is contained in:
Markus Schirp 2014-10-08 00:13:43 +00:00
parent 67573c2337
commit c7de9a24fb
6 changed files with 18 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)'