summaryrefslogtreecommitdiff
path: root/test/ruby/test_struct.rb
diff options
context:
space:
mode:
authorMatt Valentine-House <[email protected]>2023-06-12 13:13:32 +0100
committerJean Boussier <[email protected]>2023-06-12 16:20:05 +0200
commit6fe46ff967215e47ab2234e9b48663d2e3608081 (patch)
tree9c0c73d916c070a2e6b89265736aa0620ee283ff /test/ruby/test_struct.rb
parent31e24a42f3c351fc306147b08fb7442d272d39f8 (diff)
When alloc size is too large, only allocate struct
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7933
Diffstat (limited to 'test/ruby/test_struct.rb')
-rw-r--r--test/ruby/test_struct.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index 78a81c5200..ed750b91f7 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -41,6 +41,14 @@ module TestStruct
end
end
+ def test_larger_than_largest_pool
+ count = (GC::INTERNAL_CONSTANTS[:RVARGC_MAX_ALLOCATE_SIZE] / RbConfig::SIZEOF["void*"]) + 1
+ list = Array(0..count)
+ klass = @Struct.new(*list.map { |i| :"a_#{i}"})
+ struct = klass.new(*list)
+ assert_equal 0, struct.a_0
+ end
+
def test_small_structs
names = [:a, :b, :c, :d]
1.upto(4) {|n|