summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
Diffstat (limited to 'test/psych')
-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