diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-29 12:39:21 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-29 12:39:21 +0000 |
commit | eb8f91866e0bd08a6eef9c9a2bc1318e06b4ee4d (patch) | |
tree | fde6bac860df6f22615a68c9835153eefb4d6c62 /test | |
parent | 952e444877f53492ba0c8ddae7a1fe413b536ec1 (diff) |
* hash.c (rb_hash_assoc): performance improvement by replacing
compare function in RHASH(hash)->ntbl->type temporarily like r42224.
it falls back to rb_hash_foreach() if st_lookup() doesn't find the key.
* test/ruby/test_hash.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_hash.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 5694d2f01e..82eba0b352 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -879,6 +879,14 @@ class TestHash < Test::Unit::TestCase assert_equal([1.0,1], {1.0=>1}.assoc(1)) end + def test_assoc_compare_by_identity + h = {} + h.compare_by_identity + h["a"] = 1 + h["a"] = 2 + assert_equal(["a",1], h.assoc("a")) + end + def test_rassoc assert_equal([3,4], {1=>2, 3=>4, 5=>6}.rassoc(4)) assert_nil({1=>2, 3=>4, 5=>6}.rassoc(3)) |