2007-10-01 02:17:50 -04:00
|
|
|
assert_normal_exit %q{
|
|
|
|
eval("", TOPLEVEL_BINDING)
|
|
|
|
minobj = ObjectSpace.to_enum(:each_object).min_by {|a| a.object_id }
|
|
|
|
maxobj = ObjectSpace.to_enum(:each_object).max_by {|a| a.object_id }
|
2009-02-02 03:08:52 -05:00
|
|
|
(((minobj.object_id-100)..(minobj.object_id+100))+
|
|
|
|
((maxobj.object_id-100)..(maxobj.object_id+100))).each {|id|
|
2007-10-01 02:17:50 -04:00
|
|
|
begin
|
|
|
|
o = ObjectSpace._id2ref(id)
|
|
|
|
rescue RangeError
|
|
|
|
next
|
|
|
|
end
|
|
|
|
o.inspect if defined?(o.inspect)
|
|
|
|
}
|
|
|
|
}, '[ruby-dev:31911]'
|
2007-11-23 03:33:32 -05:00
|
|
|
|
|
|
|
assert_normal_exit %q{
|
|
|
|
ary = (1..10).to_a
|
|
|
|
ary.permutation(2) {|x|
|
|
|
|
if x == [1,2]
|
|
|
|
ObjectSpace.each_object(String) {|s|
|
2007-12-22 05:54:02 -05:00
|
|
|
s.clear if !s.frozen? && (s.length == 40 || s.length == 80)
|
2007-11-23 03:33:32 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}, '[ruby-dev:31982]'
|
|
|
|
|
|
|
|
assert_normal_exit %q{
|
|
|
|
ary = (1..100).to_a
|
|
|
|
ary.permutation(2) {|x|
|
|
|
|
if x == [1,2]
|
|
|
|
ObjectSpace.each_object(Array) {|o| o.clear if o == ary && o.object_id != ary.object_id }
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}, '[ruby-dev:31985]'
|
2011-07-08 00:57:27 -04:00
|
|
|
|
|
|
|
assert_normal_exit %q{
|
|
|
|
ObjectSpace.define_finalizer("") do
|
2016-08-30 02:22:30 -04:00
|
|
|
Thread::Mutex.new.lock
|
2011-07-08 00:57:27 -04:00
|
|
|
end
|
|
|
|
}, '[ruby-dev:44049]'
|
2011-07-10 03:46:00 -04:00
|
|
|
|
|
|
|
assert_normal_exit %q{
|
|
|
|
ObjectSpace.define_finalizer("") do
|
|
|
|
Thread.new {}
|
|
|
|
end
|
|
|
|
}, '[ruby-core:37858]'
|
2019-10-31 20:21:01 -04:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
objects_and_ids = 1000.times.map { o = Object.new; [o, o.object_id] }
|
|
|
|
objects_and_ids.each { |expected, id|
|
|
|
|
actual = ObjectSpace._id2ref(id)
|
|
|
|
raise "expected #{expected.inspect}, got #{actual.inspect}" unless actual.equal?(expected)
|
|
|
|
}
|
|
|
|
'ok'
|
|
|
|
}
|