diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-08 12:08:20 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-08 12:08:20 +0000 |
commit | cff2b2b66626e5aee5598f98b1f855249ca2f282 (patch) | |
tree | d2eac53c4065e0ddc4dc7c135eb512b1d47c0a25 /test | |
parent | 377758fdcba8c3655da6fd45808a69ac3c4bab82 (diff) | |
download | ruby-cff2b2b66626e5aee5598f98b1f855249ca2f282.tar.gz |
* vm_backtrace.c, include/ruby/debug.h: add new APIs
* VALUE rb_profile_frame_method_name(VALUE frame)
* VALUE rb_profile_frame_qualified_method_name(VALUE frame)
* iseq.c (rb_iseq_klass), internal.h: add new internal function
rb_iseq_method_name().
* ext/-test-/debug/profile_frames.c (profile_frames),
test/-ext-/debug/test_profile_frames.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/debug/test_profile_frames.rb | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/test/-ext-/debug/test_profile_frames.rb b/test/-ext-/debug/test_profile_frames.rb index 854f3bc2db..cca4607c73 100644 --- a/test/-ext-/debug/test_profile_frames.rb +++ b/test/-ext-/debug/test_profile_frames.rb @@ -2,8 +2,14 @@ require 'test/unit' require '-test-/debug' class SampleClassForTestProfileFrames + class Sample2 + def baz(block) + block.call + end + end + def self.bar(block) - block.call + Sample2.new.baz(block) end def foo(block) @@ -17,31 +23,49 @@ class TestProfileFrames < Test::Unit::TestCase Fiber.yield SampleClassForTestProfileFrames.new.foo(lambda{ Bug::Debug.profile_frames(0, 10) }) }.resume - assert_equal(4, frames.size) - labels = [ "block (2 levels) in test_profile_frames", + "baz", "bar", "foo", "block in test_profile_frames", ] base_labels = [ "test_profile_frames", + "baz", "bar", "foo", "test_profile_frames", ] classes = [ TestProfileFrames, + SampleClassForTestProfileFrames::Sample2, SampleClassForTestProfileFrames, # singleton method SampleClassForTestProfileFrames, TestProfileFrames, ] singleton_method_p = [ - false, true, false, false, false, + false, false, true, false, false, false, ] + methdo_names = [ + "test_profile_frames", + "baz", + "bar", + "foo", + "test_profile_frames", + ] + qualified_method_names = [ + "TestProfileFrames#test_profile_frames", + "SampleClassForTestProfileFrames::Sample2#baz", + "SampleClassForTestProfileFrames.bar", + "SampleClassForTestProfileFrames#foo", + "TestProfileFrames#test_profile_frames", + ] + + assert_equal(labels.size, frames.size) - frames.each.with_index{|(path, absolute_path, label, base_label, first_lineno, classpath, singleton_p), i| + frames.each.with_index{|(path, absolute_path, label, base_label, first_lineno, + classpath, singleton_p, method_name, qualified_method_name), i| err_msg = "#{i}th frame" assert_equal(__FILE__, path, err_msg) assert_equal(__FILE__, absolute_path, err_msg) @@ -49,6 +73,8 @@ class TestProfileFrames < Test::Unit::TestCase assert_equal(base_labels[i], base_label, err_msg) assert_equal(classes[i].to_s, classpath, err_msg) assert_equal(singleton_method_p[i], singleton_p, err_msg) + assert_equal(methdo_names[i], method_name, err_msg) + assert_equal(qualified_method_names[i], qualified_method_name, err_msg) } end end |