From ecbf8351808c2425ec081c9055c9ddd790933e8b Mon Sep 17 00:00:00 2001 From: tenderlove Date: Fri, 6 Feb 2015 08:50:00 +0000 Subject: * ext/psych/lib/psych/visitors/yaml_tree.rb: register nodes when dumping objects with custom coders. [ruby-core:66215] [Bug #10496] * test/psych/test_coder.rb: test for fix git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/psych/test_coder.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/psych/test_coder.rb b/test/psych/test_coder.rb index 7571e89..e3213e2 100644 --- a/test/psych/test_coder.rb +++ b/test/psych/test_coder.rb @@ -95,6 +95,28 @@ module Psych end end + class Referential + attr_reader :a + + def initialize + @a = self + end + + def encode_with(c) + c['a'] = @a + end + + def init_with(c) + @a = c['a'] + end + end + + def test_self_referential + x = Referential.new + copy = Psych.load Psych.dump x + assert_equal copy, copy.a + end + def test_represent_with_object thing = Psych.load(Psych.dump(RepresentWithObject.new)) assert_equal 20, thing -- cgit v1.1