summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-06-21 11:23:56 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-06-21 11:23:56 -0700
commit478a7ac57bf802c11ff5d60fd547f5b2530691b4 (patch)
tree581e42d9db3f9ec2f89dac5ef5e37375e84d6beb /test
parent75159207c2349447e4de65a529f3187f3354cf1f (diff)
downloadpsych-478a7ac57bf802c11ff5d60fd547f5b2530691b4.zip
fixing cyclic object reference handling. Thanks to @CvX for the test. fixes #19
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_object.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb
index 9890d50..6145bb6 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