mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
ext/objspace/lib/objspace/trace.rb: Added
This file, when require'ed, starts tracing the object allocations, and redefines `Kernel#p` to show the allocation site. This commit is experimental; the library name and APIs may change. [Feature #17762]
This commit is contained in:
parent
7cf90f99f5
commit
cf1e1879f1
2 changed files with 60 additions and 0 deletions
|
@ -616,4 +616,20 @@ class TestObjSpace < Test::Unit::TestCase
|
|||
assert_not_include ObjectSpace.dump(Class.new), '"name"'
|
||||
assert_not_include ObjectSpace.dump(Module.new), '"name"'
|
||||
end
|
||||
|
||||
def test_objspace_trace
|
||||
assert_in_out_err(%w[-robjspace/trace], "#{<<-"begin;"}\n#{<<-'end;'}") do |out, err|
|
||||
begin;
|
||||
a = "foo"
|
||||
b = "b" + "a" + "r"
|
||||
c = 42
|
||||
p a, b, c
|
||||
end;
|
||||
assert_equal 3, out.size
|
||||
assert_equal '"foo" @ -:2', out[0]
|
||||
assert_equal '"bar" @ -:3', out[1]
|
||||
assert_equal '42', out[2]
|
||||
assert_equal ["objspace/trace is enabled"], err
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue