Skip to content

Commit

Permalink
Add test for anchor reuse
Browse files Browse the repository at this point in the history
The spec calls this a "reuse" of an anchor
https://yaml.org/spec/1.2.2/#71-alias-nodes
  • Loading branch information
amomchilov committed Jul 27, 2022
1 parent 0c11ddc commit 57e3b70
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/psych/test_hash.rb
Expand Up @@ -112,6 +112,17 @@ def test_ref_append
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
Expand Down

0 comments on commit 57e3b70

Please sign in to comment.