diff options
Diffstat (limited to 'test/objspace/test_objspace.rb')
-rw-r--r-- | test/objspace/test_objspace.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 8a8d7ce8ea..11e69bd7e8 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -108,4 +108,22 @@ class TestObjSpace < Test::Unit::TestCase } eom end + + def test_traceobject + o0 = Object.new + ObjectSpace.trace_object_allocations{ + o1 = Object.new; line1 = __LINE__ + o2 = "a"+"b" ; line2 = __LINE__ + o3 = [1, 2] ; line3 = __LINE__ + + assert_equal(nil, ObjectSpace.allocation_sourcefile(o0)) + assert_equal(nil, ObjectSpace.allocation_sourceline(o0)) + assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o1)) + assert_equal(line1, ObjectSpace.allocation_sourceline(o1)) + assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o2)) + assert_equal(line2, ObjectSpace.allocation_sourceline(o2)) + assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o3)) + assert_equal(line3, ObjectSpace.allocation_sourceline(o3)) + } + end end |