Skip to content

Commit

Permalink
should count only string.
Browse files Browse the repository at this point in the history
This code can generate CC objects so we only need to count
existing String objects.
  • Loading branch information
ko1 committed Feb 25, 2020
1 parent 7ec2359 commit 670b7be
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/ruby/test_hash.rb
Expand Up @@ -266,10 +266,13 @@ def test_ASET # '[]='
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
Expand Down

0 comments on commit 670b7be

Please sign in to comment.