summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-26 20:16:14 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-26 20:16:14 +0000
commit72e60a04372c03e40d3954063e6e520541d5ca2d (patch)
tree3a64c81a0545e2770905e6ec7f2ac39247218a48 /test
parent6e33c16ffdabf6b8c64a49344f830a25a2b5bccf (diff)
`TracePoint#enable(target_line:)` is supported. [Feature #15289]
* vm_trace.c: `TracePoint#enable(target_line:)` is supported. This option enables a hook only at specified target_line. target_line should be combination with target and :line event. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_settracefunc.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index f1024ee082..39d8d1b3c6 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -2056,4 +2056,31 @@ class TestSetTraceFunc < Test::Unit::TestCase
end
assert_equal [:tp2, :tp2, :tp1, :tp2, :___], events
end
+
+ def test_tracepoint_enable_with_target_line
+ events = []
+ code1 = proc{
+ events << 1
+ events << 2
+ events << 3
+ }
+ tp = TracePoint.new(:line) do |tp|
+ events << :tp
+ end
+ tp.enable(target: code1, target_line: 2064) do
+ code1.call
+ end
+ assert_equal [1, :tp, 2, 3], events
+
+
+ e = assert_raise(ArgumentError) do
+ TracePoint.new(:line){}.enable(target_line: 10){}
+ end
+ assert_equal 'only target_line is specified', e.message
+
+ e = assert_raise(ArgumentError) do
+ TracePoint.new(:call){}.enable(target: code1, target_line: 10){}
+ end
+ assert_equal 'target_line is specified, but line event is not specified', e.message
+ end
end