diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2025-05-15 14:04:36 +0200 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2025-05-16 20:16:52 +0200 |
| commit | ec8900e3eb7f0008a635fb6fbabde3eb7802536b (patch) | |
| tree | 29c4e3a26a12807e9875c8474da11756664459c7 /test/ruby | |
| parent | a29442701785463d0febf5b8cf217246e927bfae (diff) | |
rb_gc_impl_copy_finalizer: generate a new object id
Fix a regression introduced by: https://github.com/ruby/ruby/pull/13155
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13350
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_objectspace.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index ef85edc5ee..f27f586ab7 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -94,7 +94,7 @@ End end def test_finalizer - assert_in_out_err(["-e", <<-END], "", %w(:ok :ok :ok :ok), []) + assert_in_out_err(["-e", <<-END], "", %w(:ok :ok :ok), []) a = [] ObjectSpace.define_finalizer(a) { p :ok } b = a.dup @@ -137,6 +137,25 @@ End } end + def test_finalizer_copy + assert_in_out_err(["-e", <<~'RUBY'], "", %w(:ok), []) + def fin + ids = Set.new + ->(id) { puts "object_id (#{id}) reused" unless ids.add?(id) } + end + + OBJ = Object.new + ObjectSpace.define_finalizer(OBJ, fin) + OBJ.freeze + + 10.times do + OBJ.clone + end + + p :ok + RUBY + end + def test_finalizer_with_super assert_in_out_err(["-e", <<-END], "", %w(:ok), []) class A |
