diff options
author | Alexander Momchilov <alexander.momchilov@shopify.com> | 2022-07-22 16:09:13 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-08-09 01:33:31 +0900 |
commit | ea1efdf32faf2cf35f6db1ec426c277bfa8f0461 (patch) | |
tree | dca53dd4adbd900b50957ce2ae7bebb15b108e29 /test/psych | |
parent | 54219ae8c46bc431782caf01142883ce7e8b970b (diff) |
[ruby/psych] Add test for anchor reuse
The spec calls this a "reuse" of an anchor
https://yaml.org/spec/1.2.2/#71-alias-nodes
https://github.com/ruby/psych/commit/57e3b70a56
Diffstat (limited to 'test/psych')
-rw-r--r-- | test/psych/test_hash.rb | 11 |
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 |