summaryrefslogtreecommitdiff
path: root/test/-ext-/debug/test_profile_frames.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-05-06 18:49:25 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2020-05-07 08:46:36 -0700
commitcbe4f75ef802f13d05f94e42274b65a062bd3666 (patch)
tree4034d45cdec1d320d38c0937ad0a425e3b731734 /test/-ext-/debug/test_profile_frames.rb
parent00698f26a9141d6226635d3c53761ef03dd8ed6b (diff)
Fix rb_profile_frame_classpath to handle module singletons
Right now `SomeClass.method` is properly named, but `SomeModule.method` is displayed as `#<Module:0x000055eb5d95adc8>.method` which makes profiling annoying.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3084
Diffstat (limited to 'test/-ext-/debug/test_profile_frames.rb')
-rw-r--r--test/-ext-/debug/test_profile_frames.rb40
1 files changed, 34 insertions, 6 deletions
diff --git a/test/-ext-/debug/test_profile_frames.rb b/test/-ext-/debug/test_profile_frames.rb
index 5ea506046e..0335267ee9 100644
--- a/test/-ext-/debug/test_profile_frames.rb
+++ b/test/-ext-/debug/test_profile_frames.rb
@@ -3,6 +3,16 @@ require 'test/unit'
require '-test-/debug'
class SampleClassForTestProfileFrames
+ class << self
+ attr_accessor :sample4
+ end
+
+ self.sample4 = Module.new do
+ def self.corge(block)
+ Sample2.new.baz(block)
+ end
+ end
+
class Sample2
def baz(block)
instance_eval "def zab(block) block.call end"
@@ -10,8 +20,16 @@ class SampleClassForTestProfileFrames
end
end
+ module Sample3
+ class << self
+ def qux(block)
+ SampleClassForTestProfileFrames.sample4.corge(block)
+ end
+ end
+ end
+
def self.bar(block)
- Sample2.new.baz(block)
+ Sample3.qux(block)
end
def foo(block)
@@ -29,6 +47,8 @@ class TestProfileFrames < Test::Unit::TestCase
"test_profile_frames",
"zab",
"baz",
+ "corge",
+ "qux",
"bar",
"foo",
"test_profile_frames",
@@ -37,6 +57,8 @@ class TestProfileFrames < Test::Unit::TestCase
"test_profile_frames",
"zab",
"baz",
+ "corge",
+ "qux",
"bar",
"foo",
"test_profile_frames",
@@ -45,6 +67,8 @@ class TestProfileFrames < Test::Unit::TestCase
"TestProfileFrames#test_profile_frames",
"#{obj.inspect}.zab",
"SampleClassForTestProfileFrames::Sample2#baz",
+ "#{SampleClassForTestProfileFrames.sample4.inspect}.corge",
+ "SampleClassForTestProfileFrames::Sample3.qux",
"SampleClassForTestProfileFrames.bar",
"SampleClassForTestProfileFrames#foo",
"TestProfileFrames#test_profile_frames",
@@ -53,17 +77,21 @@ class TestProfileFrames < Test::Unit::TestCase
TestProfileFrames,
obj,
SampleClassForTestProfileFrames::Sample2,
+ SampleClassForTestProfileFrames.sample4,
+ SampleClassForTestProfileFrames::Sample3,
SampleClassForTestProfileFrames, # singleton method
SampleClassForTestProfileFrames,
TestProfileFrames,
]
singleton_method_p = [
- false, true, false, true, false, false, false,
+ false, true, false, true, true, true, false, false, false,
]
method_names = [
"test_profile_frames",
"zab",
"baz",
+ "corge",
+ "qux",
"bar",
"foo",
"test_profile_frames",
@@ -72,14 +100,14 @@ class TestProfileFrames < Test::Unit::TestCase
"TestProfileFrames#test_profile_frames",
"#{obj.inspect}.zab",
"SampleClassForTestProfileFrames::Sample2#baz",
+ "#{SampleClassForTestProfileFrames.sample4.inspect}.corge",
+ "SampleClassForTestProfileFrames::Sample3.qux",
"SampleClassForTestProfileFrames.bar",
"SampleClassForTestProfileFrames#foo",
"TestProfileFrames#test_profile_frames",
]
- paths = [ file=__FILE__, "(eval)", file, file, file, file ]
- absolute_paths = [ file, nil, file, file, file, file ]
-
- # pp frames
+ paths = [ file=__FILE__, "(eval)", file, file, file, file, file, file ]
+ absolute_paths = [ file, nil, file, file, file, file, file, file ]
assert_equal(labels.size, frames.size)