aboutsummaryrefslogtreecommitdiffstats
path: root/test/psych/test_coder.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-06 08:50:00 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-06 08:50:00 +0000
commitecbf8351808c2425ec081c9055c9ddd790933e8b (patch)
treea17351ae161e139351f1f4d9b0f1467c5763bdcd /test/psych/test_coder.rb
parentef5b8fe12f2d1c4a24c71c7965b7e7184ad613d6 (diff)
downloadruby-ecbf8351808c2425ec081c9055c9ddd790933e8b.tar.gz
* 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
Diffstat (limited to 'test/psych/test_coder.rb')
-rw-r--r--test/psych/test_coder.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/psych/test_coder.rb b/test/psych/test_coder.rb
index 7571e89c9d..e3213e2faa 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