diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-14 10:21:04 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-14 10:21:04 +0000 |
commit | e1aa72d44104297b51d0fd05dfb5858f3ccd8522 (patch) | |
tree | 5e0cd37d5f5ba0d00218f0902ecce92d0a1f9acc | |
parent | 795c29dcda01fa81a3ccebee4433adabe6778d76 (diff) | |
download | ruby-e1aa72d44104297b51d0fd05dfb5858f3ccd8522.tar.gz |
update PP with recent Kernel#inspect change. Patch by Yusuke Endoh.
* lib/pp.rb (class PP): do not call #to_s anymore, as #inspect no more does.
* test/test_pp.rb (class PPInspectTest): remove related assertion.
[ruby-core:43238][Feature #6130]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib/pp.rb | 11 | ||||
-rw-r--r-- | test/test_pp.rb | 1 |
3 files changed, 9 insertions, 11 deletions
@@ -1,3 +1,11 @@ +Tue Aug 14 19:19:10 2012 Benoit Daloze <eregontp@gmail.com> + + update PP with recent Kernel#inspect change. Patch by Yusuke Endoh. + + * lib/pp.rb (class PP): do not call #to_s anymore, as #inspect no more does. + * test/test_pp.rb (class PPInspectTest): remove related assertion. + [ruby-core:43238][Feature #6130] + Tue Aug 14 19:09:38 2012 Benoit Daloze <eregontp@gmail.com> Kernel#inspect: improve consistency and do not call #to_s. @@ -265,8 +265,7 @@ class PP < PrettyPrint module ObjectMixin # 1. specific pretty_print # 2. specific inspect - # 3. specific to_s - # 4. generic pretty_print + # 3. generic pretty_print # A default pretty printing method for general objects. # It calls #pretty_print_instance_variables to list instance variables. @@ -283,18 +282,10 @@ class PP < PrettyPrint inspect_method = method_method.call(:inspect) rescue NameError end - begin - to_s_method = method_method.call(:to_s) - rescue NameError - end if inspect_method && /\(Kernel\)#/ !~ inspect_method.inspect q.text self.inspect elsif !inspect_method && self.respond_to?(:inspect) q.text self.inspect - 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 else q.pp_object(self) end diff --git a/test/test_pp.rb b/test/test_pp.rb index fe65287d88..acd3e835b9 100644 --- a/test/test_pp.rb +++ b/test/test_pp.rb @@ -118,7 +118,6 @@ class PPInspectTest < Test::Unit::TestCase def a.to_s() "aaa" end result = PP.pp(a, '') assert_equal("#{a.inspect}\n", result) - assert_equal("aaa\n", result) end end |