diff options
Diffstat (limited to 'test/ruby/test_objectspace.rb')
-rw-r--r-- | test/ruby/test_objectspace.rb | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index c26748f516..1c97bd517e 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -65,6 +65,14 @@ End assert_raise_with_message(TypeError, msg) {ObjectSpace._id2ref(Object.new)} end + def test_id2ref_invalid_symbol_id + # RB_STATIC_SYM_P checks for static symbols by checking that the bottom + # 8 bits of the object is equal to RUBY_SYMBOL_FLAG, so we need to make + # sure that the bottom 8 bits remain unchanged. + msg = /is not symbol id value/ + assert_raise_with_message(RangeError, msg) { ObjectSpace._id2ref(:a.object_id + 256) } + end + def test_count_objects h = {} ObjectSpace.count_objects(h) @@ -168,6 +176,33 @@ End end; end + def test_finalizer_thread_raise + GC.disable + fzer = proc do |id| + sleep 0.2 + end + 2.times do + o = Object.new + ObjectSpace.define_finalizer(o, fzer) + end + + my_error = Class.new(RuntimeError) + begin + main_th = Thread.current + Thread.new do + sleep 0.1 + main_th.raise(my_error) + end + GC.start + puts "After GC" + sleep(10) + assert(false) + rescue my_error + end + ensure + GC.enable + end + def test_each_object klass = Class.new new_obj = klass.new @@ -192,7 +227,7 @@ End assert_same(new_obj, found[0]) end - def test_each_object_no_gabage + def test_each_object_no_garbage assert_separately([], <<-End) GC.disable eval('begin; 1.times{}; rescue; ensure; end') |