diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2021-05-14 13:40:32 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2021-05-14 13:40:32 +0900 |
commit | cf1e1879f12ad547f95fe94ab62b4d960e804eb8 (patch) | |
tree | e96d145838260a4782707955ec23f5d0c6798f01 /test/objspace/test_objspace.rb | |
parent | 7cf90f99f5674fdadc0ff9d8341b315b2490ea26 (diff) |
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]
Diffstat (limited to 'test/objspace/test_objspace.rb')
-rw-r--r-- | test/objspace/test_objspace.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 7032798940..7797d199fa 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -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 |