summaryrefslogtreecommitdiff
path: root/test/psych/test_hash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/psych/test_hash.rb')
-rw-r--r--test/psych/test_hash.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index 0efa21160f..6c45da53b7 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -112,6 +112,17 @@ eoyml
assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash)
end
+ def test_anchor_reuse
+ hash = Psych.unsafe_load(<<~eoyml)
+ ---
+ foo: &foo
+ hello: world
+ bar: *foo
+ eoyml
+ assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash)
+ assert_same(hash.fetch("foo"), hash.fetch("bar"))
+ end
+
def test_recursive_hash
h = { }
h["recursive_reference"] = h