diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-13 12:52:23 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-13 12:52:23 +0000 |
commit | 50df2c8ea0c9ace45a6e879f0c0b6493ac83a5ac (patch) | |
tree | 5cb8ebecd95d17f5f861547693a0433b37274dca /test/ostruct | |
parent | 0c77840313e4f86c645b9cac362f83b3c1028105 (diff) | |
download | ruby-50df2c8ea0c9ace45a6e879f0c0b6493ac83a5ac.tar.gz ruby-50df2c8ea0c9ace45a6e879f0c0b6493ac83a5ac.tar.xz ruby-50df2c8ea0c9ace45a6e879f0c0b6493ac83a5ac.zip |
* lib/ostruct.rb (OpenStruct#inspect): fixed the recursion check.
Patch by Kornelius Kalnbach. [ruby-core:20992].
* test/ostruct/test_ostruct.rb: test for inspect.
Patch by Kornelius Kalnbach. [ruby-core:20992].
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ostruct')
-rw-r--r-- | test/ostruct/test_ostruct.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index 24ed17f80..79662c643 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -20,4 +20,18 @@ class TC_OpenStruct < Test::Unit::TestCase o2.instance_eval{@table = {:a => 'b'}} assert_not_equal(o1, o2) end + + def test_inspect + foo = OpenStruct.new + assert_equal("#<OpenStruct>", foo.inspect) + foo.bar = 1 + foo.baz = 2 + assert_equal("#<OpenStruct bar=1, baz=2>", foo.inspect) + + foo = OpenStruct.new + foo.bar = OpenStruct.new + assert_equal('#<OpenStruct bar=#<OpenStruct>>', foo.inspect) + foo.bar.foo = foo + assert_equal('#<OpenStruct bar=#<OpenStruct foo=#<OpenStruct ...>>>', foo.inspect) + end end |