summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2019-07-22 12:02:23 +0200
committerJean Boussier <jean.boussier@gmail.com>2019-07-22 19:43:32 +0200
commit0414982ffd5391f2acccfc7481b3100cc181b20d (patch)
treed11237d599b28c09a9892da3e022ad8b72a8e0a1 /test
parent34032528a7f92ab98e566c4852574c5b044c76c0 (diff)
downloadpsych-0414982ffd5391f2acccfc7481b3100cc181b20d.zip
Deduplicate hash keys if they're strings
Diffstat (limited to 'test')
-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 2a563da..ba11b82 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