diff options
| author | Peter Zhu <peter@peterzhu.ca> | 2023-06-29 11:52:48 -0400 |
|---|---|---|
| committer | Peter Zhu <peter@peterzhu.ca> | 2023-06-29 11:52:48 -0400 |
| commit | bf2c18731d50075bb64e2639c097396276196cd9 (patch) | |
| tree | c7bfd68289c094b8190cfcfae4e366227af16d8b /test/ruby | |
| parent | f0d08d11dcd404f3146c0d71d6ff743bbc6e7193 (diff) | |
Add memory leak test for allocating ST hashes
Test for commit f0d08d11dcd404f3146c0d71d6ff743bbc6e7193.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_hash.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index d9d1ca7dde..e66beef29f 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -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")) |
