summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlexander Momchilov <alexander.momchilov@shopify.com>2022-07-22 16:09:13 -0400
committerAlexander Momchilov <alexander.momchilov@shopify.com>2022-07-27 15:25:02 -0400
commit57e3b70a561fb7c822ab679b8e53e77a34ca94eb (patch)
tree9e7a976e85208a2c09f3b2a1e55a298c39145b8f /test
parent0c11ddcf4636cfa415a2d4ff5a5222830605b086 (diff)
downloadpsych-57e3b70a561fb7c822ab679b8e53e77a34ca94eb.tar.gz
Add test for anchor reuse
The spec calls this a "reuse" of an anchor https://yaml.org/spec/1.2.2/#71-alias-nodes
Diffstat (limited to 'test')
-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 0efa211..6c45da5 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