diff options
| author | Luke Gruber <luke.gruber@shopify.com> | 2025-12-01 16:51:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-01 16:51:29 -0500 |
| commit | a8b49ab48703dfb8862ca28a443da0e764d692c6 (patch) | |
| tree | c1c6c644e544f0c641560292662fdbf1611ea172 /test/ruby | |
| parent | f92001344d0595bb6ef3a9576853edf1fa7588ca (diff) | |
Test CC invalidation for singleton classes of objects (#15360)
I made a recent change where all the tests passed but it turns out it
was still wrong. We didn't have any tests for CC invalidation on
singletons of objects that aren't classes or modules.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_class.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index f40817e7a1..10b7655e9a 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -887,4 +887,34 @@ CODE class C; end end; end + + def test_singleton_cc_invalidation + assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}") + begin; + class T + def hi + "hi" + end + end + + t = T.new + t.singleton_class + + def hello(t) + t.hi + end + + 5.times do + hello(t) # populate inline cache on `t.singleton_class`. + end + + class T + remove_method :hi # invalidate `t.singleton_class` ccs for `hi` + end + + assert_raise NoMethodError do + hello(t) + end + end; + end end |
