8000 update PP with recent Kernel#inspect change. Patch by Yusuke Endoh. · ruby/ruby@e1aa72d · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit e1aa72d

Browse files
committed
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
1 parent 795c29d commit e1aa72d

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Tue Aug 14 19:19:10 2012 Benoit Daloze <eregontp@gmail.com>
2+
3+
update PP with recent Kernel#inspect change. Patch by Yusuke Endoh.
4+
5+
* lib/pp.rb (class PP): do not call #to_s anymore, as #inspect no more does.
6+
* test/test_pp.rb (class PPInspectTest): remove related assertion.
7+
[ruby-core:43238][Feature #6130]
8+
19
Tue Aug 14 19:09:38 2012 Benoit Daloze <eregontp@gmail.com>
210

311
Kernel#inspect: improve consistency and do not call #to_s.

lib/pp.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ class SingleLine < PrettyPrint::SingleLine
265265
module ObjectMixin
266266
# 1. specific pretty_print
267267
# 2. specific inspect
268-
# 3. specific to_s
269-
# 4. generic pretty_print
268+
# 3. generic pretty_print
270269

271270
# A default pretty printing method for general objects.
272271
# It calls #pretty_print_instance_variables to list instance variables.
@@ -283,18 +282,10 @@ def pretty_print(q)
283282
inspect_method = method_method.call(:inspect)
284283
rescue NameError
285284
end
286-
begin
287-
to_s_method = method_method.call(:to_s)
288-
rescue NameError
289-
end
290285
if inspect_method && /\(Kernel\)#/ !~ inspect_method.inspect
291286
q.text self.inspect
292287
elsif !inspect_method && self.respond_to?(:inspect)
293288
q.text self.inspect
294-
elsif to_s_method && /\(Kernel\)#/ !~ to_s_method.inspect
295-
q.text self.to_s
296-
elsif !to_s_method && self.respond_to?(:to_s)
297-
q.text self.to_s
298289
else
299290
q.pp_object(self)
300291
end

test/test_pp.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def test_to_s_without_iv
118118
def a.to_s() "aaa" end
119119
result = PP.pp(a, '')
120120
assert_equal("#{a.inspect}\n", result)
121-
assert_equal("aaa\n", result)
122121
end
123122
end
124123

0 commit comments

Comments
 (0)
0