summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2019-07-22 12:02:23 +0200
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-25 07:52:16 +0900
commit6ca7dc69effddeb63a8fb8f759e29ff8649907ec (patch)
tree494129204c3267867ceb74731f397b93bfe00466 /test/psych
parent50076903ab06e2301051e459925afea20325ba7c (diff)
downloadruby-6ca7dc69effddeb63a8fb8f759e29ff8649907ec.tar.gz
[ruby/psych] Deduplicate hash keys if they're strings
https://github.com/ruby/psych/commit/0414982ffd
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_hash.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index 2a563da1da..ba11b827da 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -111,5 +111,19 @@ bar:
eoyml
assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash)
end
+
+ def test_key_deduplication
+ unless String.method_defined?(:-@) && (-("a" * 20)).equal?((-("a" * 20)))
+ skip "This Ruby implementation doesn't support string deduplication"
+ end
+
+ hashes = Psych.load(<<-eoyml)
+---
+- unique_identifier: 1
+- unique_identifier: 2
+eoyml
+
+ assert_same hashes[0].keys.first, hashes[1].keys.first
+ end
end
end