diff options
author | Jean Boussier <[email protected]> | 2023-04-13 12:11:14 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2023-04-13 16:36:17 +0200 |
commit | ac123f167a364c3d7a43eca78d564e41f6dbb91e (patch) | |
tree | 76c34bd65a5942ce9ef38e1753943e83082f08ee /test/ruby/test_object.rb | |
parent | 854baee2c936006d7f38ebb27ee577c00afc6249 (diff) |
Emit a performance warning when a class reached max variations
[Feature #19538]
This new `peformance` warning category is disabled by default.
It needs to be specifically enabled via `-W:performance` or `Warning[:performance] = true`
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7708
Diffstat (limited to 'test/ruby/test_object.rb')
-rw-r--r-- | test/ruby/test_object.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 26256b80db..a34fc7813a 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -422,6 +422,18 @@ class TestObject < Test::Unit::TestCase assert_equal(1+3+5+7+9, n) end + def test_max_shape_variation_with_performance_warnings + assert_in_out_err([], <<-INPUT, %w(), /Maximum shapes variations \(8\) reached by Foo, instance variables accesses will be slower\.$/) + $VERBOSE = true + Warning[:performance] = true + + class Foo; end + 10.times do |i| + Foo.new.instance_variable_set(:"@a\#{i}", nil) + end + INPUT + end + def test_redefine_method_under_verbose assert_in_out_err([], <<-INPUT, %w(2), /warning: method redefined; discarding old foo$/) $VERBOSE = true |