Do not try to load source of rbx precompiled libraries

This commit is contained in:
Markus Schirp 2013-01-03 23:32:17 +01:00
parent 0ba661b4f1
commit 7aab983b8e

View file

@ -16,6 +16,10 @@ module Mutant
Classifier.run(input)
end
# Methods within rbx kernel directory are precompiled and their source
# cannot be accessed via reading source location
BLACKLIST = %r(\Akernel/).freeze
# Enumerate matches
#
# @return [Enumerable]
@ -29,10 +33,7 @@ module Mutant
def each(&block)
return to_enum unless block_given?
unless source_location
$stderr.puts "#{method.inspect} does not have source location unable to emit matcher"
return self
end
return self if skip?
subject.tap do |subject|
yield subject if subject
@ -96,6 +97,26 @@ module Mutant
public?
end
# Test if method is skipped
#
# @return [true]
# true and print warning if location must be filtered
#
# @return [false]
# otherwise
#
# @api private
#
def skip?
location = source_location
if location.nil? or BLACKLIST.match(location.first)
$stderr.puts "#{method.inspect} does not have valid source location so mutant is unable to emit matcher"
return true
end
false
end
# Return context
#
# @return [Context::Scope]