[前][次][番号順一覧][スレッド一覧]

ruby-changes:72871

From: Alexander <ko1@a...>
Date: Tue, 9 Aug 2022 01:33:46 +0900 (JST)
Subject: [ruby-changes:72871] ea1efdf32f (master): [ruby/psych] Add test for anchor reuse

https://git.ruby-lang.org/ruby.git/commit/?id=ea1efdf32f

From ea1efdf32faf2cf35f6db1ec426c277bfa8f0461 Mon Sep 17 00:00:00 2001
From: Alexander Momchilov <alexander.momchilov@s...>
Date: Fri, 22 Jul 2022 16:09:13 -0400
Subject: [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
---
 test/psych/test_hash.rb | 11 +++++++++++
 1 file changed, 11 insertions(+)

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 https://github.com/ruby/ruby/blob/trunk/test/psych/test_hash.rb#L112
       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
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]