mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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
This commit is contained in:
parent
54219ae8c4
commit
ea1efdf32f
1 changed files with 11 additions and 0 deletions
|
@ -112,6 +112,17 @@ eoyml
|
||||||
assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash)
|
assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash)
|
||||||
end
|
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
|
def test_recursive_hash
|
||||||
h = { }
|
h = { }
|
||||||
h["recursive_reference"] = h
|
h["recursive_reference"] = h
|
||||||
|
|
Loading…
Add table
Reference in a new issue