diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-17 20:28:51 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-17 20:28:51 +0000 |
commit | 6247099f4c85a43c0405d1f4536cea99b37a652a (patch) | |
tree | 0c75755809a4c683dac52dc02f4ab85b18de7c7b /test/ruby/test_settracefunc.rb | |
parent | 4654d75ea31041d5ab90a4ead43b53743f20f391 (diff) | |
download | ruby-6247099f4c85a43c0405d1f4536cea99b37a652a.tar.gz |
* vm_trace.c (fill_id_and_klass): TracePoint#defined_class returns
singleton class. `set_trace_func' passed attached class (which is
attached/modified by singleton class) by 6th block parameter if it
is singleton class. Previous behavior follows this spec.
However, this method named `defined_class' should return singleton
class directly because singleton methods are defined in singleton
class. There are no compatible issue because TracePoint is introduced
after 2.0.
But compatiblity with `set_trace_func' is brokne. This means that
you can not replace all `set_trace_func' code with TracePoint
without consideration of this behavior.
[Bug #7554]
* test/ruby/test_settracefunc.rb: change a test to catch up
an above chagne.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_settracefunc.rb')
-rw-r--r-- | test/ruby/test_settracefunc.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index c6738494ae..0a30d04c02 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -418,12 +418,28 @@ class TestSetTraceFunc < Test::Unit::TestCase :nothing end } + _defined_class = lambda{|tp| + klass = tp.defined_class + begin + # If it is singleton method, then return original class + # to make compatible with set_trace_func(). + # This is very ad-hoc hack. I hope I can make more clean test on it. + case klass.inspect + when /Class:TracePoint/; return TracePoint + when /Class:Exception/; return Exception + else klass + klass + end + rescue Exception => e + e + end if klass + } trace = nil begin eval <<-EOF.gsub(/^.*?: /, ""), nil, 'xyzzy' 1: trace = TracePoint.trace(*trace_events){|tp| - 2: events << [tp.event, tp.lineno, tp.path, tp.defined_class, tp.method_id, tp.self, tp.binding.eval("_local_var"), _get_data.(tp)] + 2: events << [tp.event, tp.lineno, tp.path, _defined_class.(tp), tp.method_id, tp.self, tp.binding.eval("_local_var"), _get_data.(tp)] 3: } 4: 1.times{|;_local_var| _local_var = :inner 5: tap{} |