mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/pp.rb (Struct#pretty_print_cycle): follow 1.8 style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
18afa51bd2
commit
223a2a6677
2 changed files with 11 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Tue Feb 3 08:04:57 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
* lib/pp.rb (Struct#pretty_print_cycle): follow 1.8 style.
|
||||||
|
|
||||||
Mon Feb 2 19:33:49 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
Mon Feb 2 19:33:49 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in: backport from 1.9 for Interix.
|
* configure.in: backport from 1.9 for Interix.
|
||||||
|
|
10
lib/pp.rb
10
lib/pp.rb
|
@ -324,7 +324,7 @@ class Struct
|
||||||
end
|
end
|
||||||
|
|
||||||
def pretty_print_cycle(q)
|
def pretty_print_cycle(q)
|
||||||
q.text sprintf("#<%s:...>", self.class.name)
|
q.text sprintf("#<struct %s:...>", self.class.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ if __FILE__ == $0
|
||||||
result = PP.pp(a, '')
|
result = PP.pp(a, '')
|
||||||
assert_equal("#{a.inspect}\n", result)
|
assert_equal("#{a.inspect}\n", result)
|
||||||
assert_match(/\A#<Object.*>\n\z/m, result)
|
assert_match(/\A#<Object.*>\n\z/m, result)
|
||||||
a = 1
|
a = 1.0
|
||||||
a.instance_eval { @a = nil }
|
a.instance_eval { @a = nil }
|
||||||
result = PP.pp(a, '')
|
result = PP.pp(a, '')
|
||||||
assert_equal("#{a.inspect}\n", result)
|
assert_equal("#{a.inspect}\n", result)
|
||||||
|
@ -562,19 +562,22 @@ if __FILE__ == $0
|
||||||
a = []
|
a = []
|
||||||
a << a
|
a << a
|
||||||
assert_equal("[[...]]\n", PP.pp(a, ''))
|
assert_equal("[[...]]\n", PP.pp(a, ''))
|
||||||
|
assert_equal("#{a.inspect}\n", PP.pp(a, ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hash
|
def test_hash
|
||||||
a = {}
|
a = {}
|
||||||
a[0] = a
|
a[0] = a
|
||||||
assert_equal("{0=>{...}}\n", PP.pp(a, ''))
|
assert_equal("{0=>{...}}\n", PP.pp(a, ''))
|
||||||
|
assert_equal("#{a.inspect}\n", PP.pp(a, ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
S = Struct.new("S", :a, :b)
|
S = Struct.new("S", :a, :b)
|
||||||
def test_struct
|
def test_struct
|
||||||
a = S.new(1,2)
|
a = S.new(1,2)
|
||||||
a.b = a
|
a.b = a
|
||||||
assert_equal("#<struct Struct::S a=1, b=#<Struct::S:...>>\n", PP.pp(a, ''))
|
assert_equal("#<struct Struct::S a=1, b=#<struct Struct::S:...>>\n", PP.pp(a, ''))
|
||||||
|
assert_equal("#{a.inspect}\n", PP.pp(a, ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_object
|
def test_object
|
||||||
|
@ -592,6 +595,7 @@ if __FILE__ == $0
|
||||||
a = []
|
a = []
|
||||||
a << HasInspect.new(a)
|
a << HasInspect.new(a)
|
||||||
assert_equal("[<inspect:[...]>]\n", PP.pp(a, ''))
|
assert_equal("[<inspect:[...]>]\n", PP.pp(a, ''))
|
||||||
|
assert_equal("#{a.inspect}\n", PP.pp(a, ''))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_share_nil
|
def test_share_nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue