7be00708b6
* Expand foo? to foo_predicate_spec.rb * Expand foo! to foo_bang_spec.rb * Execute all public method specs on mutation of private method * Warn on stderr when no spec file was found (better than nothing to be iproved later)
66 lines
1.3 KiB
Ruby
66 lines
1.3 KiB
Ruby
module Mutant
|
|
class Matcher
|
|
class Method < self
|
|
# Matcher for instance methods
|
|
class Instance < self
|
|
|
|
|
|
# Return identification
|
|
#
|
|
# @return [String]
|
|
#
|
|
# @api private
|
|
#
|
|
def identification
|
|
"#{scope.name}##{method_name}"
|
|
end
|
|
|
|
# Test if method is public
|
|
#
|
|
# @return [true]
|
|
# if method is public
|
|
#
|
|
# @return [false]
|
|
# otherwise
|
|
#
|
|
# @api private
|
|
#
|
|
def public?
|
|
scope.public_method_defined?(method_name)
|
|
end
|
|
|
|
private
|
|
|
|
# Check if node is matched
|
|
#
|
|
# @param [Rubinius::AST::Node] node
|
|
#
|
|
# @return [true]
|
|
# returns true if node matches method
|
|
#
|
|
# @return [false]
|
|
# returns false if node NOT matches method
|
|
#
|
|
# @api private
|
|
#
|
|
def match?(node)
|
|
node.line == source_line &&
|
|
node.class == Rubinius::AST::Define &&
|
|
node.name == method_name
|
|
end
|
|
|
|
# Return method instance
|
|
#
|
|
# @return [UnboundMethod]
|
|
#
|
|
# @api private
|
|
#
|
|
def method
|
|
scope.instance_method(method_name)
|
|
end
|
|
memoize :method, :freezer => :noop
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|