From 0b7cfdca09651f2eae5cd0e8ae4efed5033493f2 Mon Sep 17 00:00:00 2001 From: Alexander Momchilov Date: Fri, 22 Jul 2022 16:45:03 -0400 Subject: [ruby/psych] Test that recursive refs dump as aliases https://github.com/ruby/psych/commit/d9f7289190 --- test/psych/test_hash.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/psych/test_hash.rb') diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index 5374781339..43e4b8bf14 100644 --- a/test/psych/test_hash.rb +++ b/test/psych/test_hash.rb @@ -112,6 +112,18 @@ eoyml assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash) end + def test_recursive_hash_uses_alias + h = { } + h["recursive_reference"] = h + + expected = <<~eoyaml + --- &1 + recursive_reference: *1 + eoyaml + + assert_equal(expected, Psych.dump(h)) + end + def test_key_deduplication unless String.method_defined?(:-@) && (-("a" * 20)).equal?((-("a" * 20))) pend "This Ruby implementation doesn't support string deduplication" -- cgit v1.2.3