From d7ca93c62c8319659842c6a06a38d64a7d3db712 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Wed, 29 Aug 2012 09:56:05 +0300 Subject: [PATCH] Revert "Add support of aliases for `Method`" This reverts commits: 905bab4d7cc2e5645f35206170d2166a47a416cf be626cfadab6afc67b94d65d3af37c2965819985 The problem is that Travis CI does not like tests for some reason. Signed-off-by: Kyrylo Silin --- lib/pry/commands/stat.rb | 3 --- lib/pry/method.rb | 18 ---------------- test/test_method.rb | 44 ---------------------------------------- 3 files changed, 65 deletions(-) diff --git a/lib/pry/commands/stat.rb b/lib/pry/commands/stat.rb index 86c83cbd..84a3c47f 100644 --- a/lib/pry/commands/stat.rb +++ b/lib/pry/commands/stat.rb @@ -16,13 +16,10 @@ class Pry def process meth = method_object - aliases = meth.aliases - output.puts unindent <<-EOS Method Information: -- Name: #{meth.name} - Alias#{ "es" if aliases.length > 1 }: #{ aliases.any? ? aliases.join(", ") : "None." } Owner: #{meth.owner ? meth.owner : "Unknown"} Visibility: #{meth.visibility} Type: #{meth.is_a?(::Method) ? "Bound" : "Unbound"} diff --git a/lib/pry/method.rb b/lib/pry/method.rb index c3312e4c..99eb086b 100644 --- a/lib/pry/method.rb +++ b/lib/pry/method.rb @@ -403,24 +403,6 @@ class Pry source_file == Pry.eval_path end - # @return [Array] All known aliases for the method. - # @note On Ruby 1.8 this method always returns an empty Array for methods - # implemented in C. - def aliases - owner = @method.owner - # Avoid using `to_sym` on {Method#name}, which returns a `String`, because - # it won't be garbage collected. - name = @method.name - - alias_list = owner.instance_methods.combination(2).select do |pair| - owner.instance_method(pair.first) == owner.instance_method(pair.last) && - pair.include?(name) - end.flatten - alias_list.delete(name) - - alias_list.map(&:to_s) - end - # @return [Boolean] Is the method definitely an alias? def alias? name != original_name diff --git a/test/test_method.rb b/test/test_method.rb index f4b895f8..dcf9258c 100644 --- a/test/test_method.rb +++ b/test/test_method.rb @@ -1,5 +1,4 @@ require 'helper' -require 'set' describe Pry::Method do it "should use String names for compatibility" do @@ -398,48 +397,5 @@ describe Pry::Method do meth.send(:method_name_from_first_line, "def obj_name.x").should == "x" end end - - describe 'method aliases' do - before do - @class = Class.new { - def eat - end - - alias fress eat - alias_method :omnomnom, :fress - - def eruct - end - } - end - - it 'should be able to find method aliases' do - meth = Pry::Method(@class.new.method(:eat)) - aliases = Set.new(meth.aliases) - - aliases.should == Set.new(["fress", "omnomnom"]) - end - - it 'should return an empty Array if cannot find aliases' do - meth = Pry::Method(@class.new.method(:eruct)) - meth.aliases.should.be.empty - end - - it 'should not include the own name in the list of aliases' do - meth = Pry::Method(@class.new.method(:eat)) - meth.aliases.should.not.include "eat" - 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 - meth = Pry::Method(Hash.new.method(:key?)) - aliases = Set.new(meth.aliases) - - aliases.should == Set.new(["include?", "member?", "has_key?"]) - end - end - - end end