summaryrefslogtreecommitdiff
path: root/lib/pp.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-07 10:06:41 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-07 10:06:41 +0000
commitf5be4ddc8d2d76f8d3543c5ecfd852199b20b7d2 (patch)
tree9836dbbd2b38405f4b77a89969144deb4788681b /lib/pp.rb
parentaecbd392eb867ad642c22e5f2d22a63c68a0d647 (diff)
* lib/pp.rb: call original "method" method instead of redefined one.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/pp.rb')
-rw-r--r--lib/pp.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index 8080d879f9..14fe62ee95 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -255,9 +255,9 @@ class PP < PrettyPrint
# This module provides predefined #pretty_print methods for some of
# the most commonly used built-in classes for convenience.
def pretty_print(q)
- if /\(Kernel\)#/ !~ method(:inspect).inspect
+ if /\(Kernel\)#/ !~ Object.instance_method(:method).bind(self).call(:inspect).inspect
q.text self.inspect
- elsif /\(Kernel\)#/ !~ method(:to_s).inspect && instance_variables.empty?
+ elsif /\(Kernel\)#/ !~ Object.instance_method(:method).bind(self).call(:to_s).inspect && instance_variables.empty?
q.text self.to_s
else
q.pp_object(self)
@@ -289,7 +289,7 @@ class PP < PrettyPrint
# However, doing this requires that every class that #inspect is called on
# implement #pretty_print, or a RuntimeError will be raised.
def pretty_print_inspect
- if /\(PP::ObjectMixin\)#/ =~ method(:pretty_print).inspect
+ if /\(PP::ObjectMixin\)#/ =~ Object.instance_method(:method).bind(self).call(:pretty_print).inspect
raise "pretty_print is not overridden for #{self.class}"
end
PP.singleline_pp(self, '')
@@ -488,6 +488,13 @@ if __FILE__ == $0
a = OverriddenStruct.new(1,2)
assert_equal("#<struct Struct::OverriddenStruct members=1, class=2>\n", PP.pp(a, ''))
end
+
+ def test_redefined_method
+ o = ""
+ def o.method
+ end
+ assert_equal(%(""\n), PP.pp(o, ""))
+ end
end
class HasInspect