* lib/pp.rb (Struct#pretty_print): make it 1.8 style.
(Numeric#pretty_print, FalseClass#pretty_print) (TrueClass#pretty_print, Module#pretty_print): fix pp for objects with instance variables. [ruby-talk:91157] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
678e4ea5b4
commit
d837280dc8
@ -1,4 +1,9 @@
|
||||
Mon Feb 2 00:28:54 2004 Tanaka Akira <akr@m17n.org>
|
||||
Mon Feb 2 01:54:00 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/pp.rb (Struct#pretty_print): make it 1.8 style.
|
||||
(Numeric#pretty_print, FalseClass#pretty_print)
|
||||
(TrueClass#pretty_print, Module#pretty_print): fix pp for objects
|
||||
with instance variables. [ruby-talk:91157]
|
||||
|
||||
* lib/open-uri.rb (URI::Generic#find_proxy): return nil on loopback
|
||||
address.
|
||||
@ -22,7 +27,7 @@ Sun Feb 1 05:30:06 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/open-uri.rb (URI::Generic#find_proxy): warn HTTP_PROXY.
|
||||
raise an errror on non-http proxy URI.
|
||||
(OpenURI::Buffer#<<): make a tempfile binmode.
|
||||
(OpenURI::Buffer#<<): make a tempfile binmode. [ruby-talk:90792]
|
||||
|
||||
Sun Feb 1 00:57:41 2004 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
|
16
lib/pp.rb
16
lib/pp.rb
@ -309,7 +309,7 @@ end
|
||||
|
||||
class Struct
|
||||
def pretty_print(q)
|
||||
q.object_group(self) {
|
||||
q.group(1, '#<struct ' + self.class.name, '>') {
|
||||
self.members.each {|member|
|
||||
q.text "," unless q.first?
|
||||
q.breakable
|
||||
@ -440,6 +440,14 @@ end
|
||||
}
|
||||
}
|
||||
|
||||
[Numeric, FalseClass, TrueClass, Module].each {|c|
|
||||
c.class_eval {
|
||||
def pretty_print(q)
|
||||
q.text inspect
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
if __FILE__ == $0
|
||||
require 'test/unit'
|
||||
|
||||
@ -534,6 +542,10 @@ if __FILE__ == $0
|
||||
result = PP.pp(a, '')
|
||||
assert_equal("#{a.inspect}\n", result)
|
||||
assert_match(/\A#<Object.*>\n\z/m, result)
|
||||
a = 1
|
||||
a.instance_eval { @a = nil }
|
||||
result = PP.pp(a, '')
|
||||
assert_equal("#{a.inspect}\n", result)
|
||||
end
|
||||
|
||||
def test_to_s_without_iv
|
||||
@ -562,7 +574,7 @@ if __FILE__ == $0
|
||||
def test_struct
|
||||
a = S.new(1,2)
|
||||
a.b = a
|
||||
assert_equal("#<Struct::S a=1, b=#<Struct::S:...>>\n", PP.pp(a, ''))
|
||||
assert_equal("#<struct Struct::S a=1, b=#<Struct::S:...>>\n", PP.pp(a, ''))
|
||||
end
|
||||
|
||||
def test_object
|
||||
|
Loading…
x
Reference in New Issue
Block a user