summaryrefslogtreecommitdiff
path: root/test/ruby/test_hash.rb
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-02-25 13:12:53 +0900
committerKoichi Sasada <ko1@atdot.net>2020-02-25 13:12:53 +0900
commit670b7be6c5fb9c3438fb6e36070401f25806f725 (patch)
tree36ae418544eab30520ad2613304a4205801c93aa /test/ruby/test_hash.rb
parent7ec23593746c8ccabd6c005cc34dde77d564c6c9 (diff)
should count only string.
This code can generate CC objects so we only need to count existing String objects.
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r--test/ruby/test_hash.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 98ddbef1eb..3c799b7a04 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -266,10 +266,13 @@ class TestHash < Test::Unit::TestCase
end
def test_AREF_fstring_key
+ # warmup ObjectSpace.count_objects
+ ObjectSpace.count_objects
+
h = {"abc" => 1}
- before = GC.stat(:total_allocated_objects)
+ before = ObjectSpace.count_objects[:T_STRING]
5.times{ h["abc"] }
- assert_equal before, GC.stat(:total_allocated_objects)
+ assert_equal before, ObjectSpace.count_objects[:T_STRING]
end
def test_ASET_fstring_key