aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-07 12:05:38 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-07 12:05:38 +0000
commit4319b48ab6aef267f1ff3e1e0a68b8d63a193765 (patch)
tree9b701a195ea778fd1323ef69976f6f4f4b5f4889
parent52ebc24487f3d1553c436c3ab9fbf8784379961d (diff)
downloadruby-4319b48ab6aef267f1ff3e1e0a68b8d63a193765.tar.gz
* lib/pp.rb (PP::ObjectMixin#pretty_print): use to_s regardless of
instance variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/pp.rb5
-rw-r--r--test/test_pp.rb1
3 files changed, 7 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 3d59e8f21a..82ceb5a08d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Nov 7 21:02:57 2009 Tanaka Akira <akr@fsij.org>
+
+ * lib/pp.rb (PP::ObjectMixin#pretty_print): use to_s regardless of
+ instance variables.
+
Sat Nov 7 20:59:11 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_push_frame): get rid of out-of-bounds
diff --git a/lib/pp.rb b/lib/pp.rb
index b02e954a7d..2fcb4af820 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -270,7 +270,7 @@ class PP < PrettyPrint
module ObjectMixin
# 1. specific pretty_print
# 2. specific inspect
- # 3. specific to_s if instance variable is empty
+ # 3. specific to_s
# 4. generic pretty_print
# A default pretty printing method for general objects.
@@ -296,8 +296,7 @@ class PP < PrettyPrint
q.text self.inspect
elsif !inspect_method && self.respond_to?(:inspect)
q.text self.inspect
- elsif to_s_method && /\(Kernel\)#/ !~ to_s_method.inspect &&
- instance_variables.empty?
+ elsif to_s_method && /\(Kernel\)#/ !~ to_s_method.inspect
q.text self.to_s
elsif !to_s_method && self.respond_to?(:to_s)
q.text self.to_s
diff --git a/test/test_pp.rb b/test/test_pp.rb
index 604cbc509e..fe65287d88 100644
--- a/test/test_pp.rb
+++ b/test/test_pp.rb
@@ -107,7 +107,6 @@ class PPInspectTest < Test::Unit::TestCase
a.instance_eval { @a = nil }
result = PP.pp(a, '')
assert_equal("#{a.inspect}\n", result)
- assert_match(/\A#<Object.*>\n\z/m, result)
a = 1.0
a.instance_eval { @a = nil }
result = PP.pp(a, '')