Stat now supports top-level method aliases

FIX #812
This commit is contained in:
Aldric Giacomoni 2013-11-15 21:37:42 -05:00
parent f72ff1ab88
commit 50733344ae
2 changed files with 14 additions and 1 deletions

View File

@ -410,7 +410,8 @@ class Pry
# it won't be garbage collected.
name = @method.name
alias_list = owner.instance_methods.combination(2).select do |pair|
all_methods_to_compare = owner.instance_methods | owner.private_instance_methods
alias_list = all_methods_to_compare.combination(2).select do |pair|
pair.include?(name) &&
owner.instance_method(pair.first) == owner.instance_method(pair.last)
end.flatten

View File

@ -468,6 +468,18 @@ describe Pry::Method do
meth.aliases.should.not.include "eat"
end
it 'should find aliases for top-level methods' do
# top-level methods get added as private instance methods on Object
class Object
private
def my_top_level_method ; end
alias my_other_top_level_method my_top_level_method
end
meth = Pry::Method.new(method(:my_top_level_method))
meth.aliases.should.include 'my_other_top_level_method'
end
unless Pry::Helpers::BaseHelpers.mri_18?
# Ruby 1.8 doesn't support this feature.
it 'should be able to find aliases for methods implemented in C' do