diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-21 18:22:54 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-21 18:22:54 +0000 |
commit | 40508ede731122cdf2d13d39477317a529d4d4fd (patch) | |
tree | efc28209b32ab9ded7e827d73b200107d728685d /test/psych | |
parent | 7c5fdec05da5a6ba0a77224e241639d49a205a6c (diff) | |
download | ruby-40508ede731122cdf2d13d39477317a529d4d4fd.tar.gz |
* ext/psych/lib/psych/visitors/to_ruby.rb: Fix cyclic references of
objects. Thanks to CvX for reporting the bug and a test case.
* test/psych/test_object.rb: test for cyclic object references.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych')
-rw-r--r-- | test/psych/test_object.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb index 9890d5072a..6145bb6ada 100644 --- a/test/psych/test_object.rb +++ b/test/psych/test_object.rb @@ -11,6 +11,14 @@ module Psych end end + class Foo + attr_accessor :parent + + def initialize parent + @parent = parent + end + end + class TestObject < TestCase def test_dump_with_tag tag = Tagged.new @@ -23,5 +31,14 @@ module Psych assert_equal tag.baz, tag2.baz assert_instance_of(Tagged, tag2) end + + def test_cyclic_references + foo = Foo.new(nil) + foo.parent = foo + loaded = Psych.load Psych.dump foo + + assert_instance_of(Foo, loaded) + assert_equal loaded, loaded.parent + end end end |