Add memory leak test for allocating ST hashes

Test for commit f0d08d11dcd404f3146c0d71d6ff743bbc6e7193.
This commit is contained in:
Peter Zhu 2023-06-29 11:52:48 -04:00
parent f0d08d11dc
commit bf2c18731d

View File

@ -219,6 +219,15 @@ class TestHash < Test::Unit::TestCase
assert_equal('default', h['spurious'])
end
def test_st_literal_memory_leak
assert_no_memory_leak([], "", "#{<<~'end;'}", rss: true)
1_000_000.times do
# >8 element hashes are ST allocated rather than AR allocated
{a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9}
end
end;
end
def test_try_convert
assert_equal({1=>2}, Hash.try_convert({1=>2}))
assert_equal(nil, Hash.try_convert("1=>2"))