summaryrefslogtreecommitdiff
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-26 05:32:47 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-26 05:32:47 +0000
commit1e83e15ab55c427fe89c7497d7d813b5a884401f (patch)
tree4223d582bbddf1a11b8f733fd3de53b4d7508d83 /test/ruby/test_hash.rb
parent7cc758f7a84f8207e8e589d3cb8a8cbc813cfd88 (diff)
hash.c: aset deduplicates un-tainted string
We revisit [Bug #9188] since st.c is much improved since then, and benchmarks against so_k_nucleotide seem to indicate little or no performance change compared to before. [ruby-core:89555] [Feature #15251] From: Anmol Chopra <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 6aaeddc9d4..03ebd38f1f 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -280,6 +280,24 @@ class TestHash < Test::Unit::TestCase
assert_same a.keys[0], b.keys[0]
end
+ def test_ASET_fstring_non_literal_key
+ underscore = "_"
+ non_literal_strings = Proc.new{ ["abc#{underscore}def", "abc" * 5, "abc" + "def", "" << "ghi" << "jkl"] }
+
+ a, b = {}, {}
+ non_literal_strings.call.each do |string|
+ assert_equal 1, a[string] = 1
+ end
+
+ non_literal_strings.call.each do |string|
+ assert_equal 1, b[string] = 1
+ end
+
+ [a.keys, b.keys].transpose.each do |key_a, key_b|
+ assert_same key_a, key_b
+ end
+ end
+
def test_hash_aset_fstring_identity
h = {}.compare_by_identity
h['abc'] = 1