aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-09 22:04:47 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-09 22:04:47 +0000
commit8122d9b4241a54d10fdb5b25d8810c9d6b587d88 (patch)
treea025adac0d57113fcd548e9d59f3f6299196452f
parent294e7117493a8e38244f8a1011477f74982c1a66 (diff)
downloadruby-8122d9b4241a54d10fdb5b25d8810c9d6b587d88.tar.gz
TracePoint.new: raise ArgumentError when no block given [#14074]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_settracefunc.rb4
-rw-r--r--vm_trace.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 15a8d8b98e..74c092c460 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -1770,4 +1770,8 @@ class TestSetTraceFunc < Test::Unit::TestCase
end
}, bug13705
end
+
+ def test_trace_point_require_block
+ assert_raise(ArgumentError) { TracePoint.new(:return) }
+ end
end
diff --git a/vm_trace.c b/vm_trace.c
index 7f31de3305..beea1ecb8f 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -1238,7 +1238,7 @@ rb_tracepoint_new(VALUE target_thval, rb_event_flag_t events, void (*func)(VALUE
*
* See TracePoint@Events for possible events and more information.
*
- * A block must be given, otherwise a ThreadError is raised.
+ * A block must be given, otherwise an ArgumentError is raised.
*
* If the trace method isn't included in the given events filter, a
* RuntimeError is raised.
@@ -1274,7 +1274,7 @@ tracepoint_new_s(int argc, VALUE *argv, VALUE self)
}
if (!rb_block_given_p()) {
- rb_raise(rb_eThreadError, "must be called with a block");
+ rb_raise(rb_eArgError, "must be called with a block");
}
return tracepoint_new(self, 0, events, 0, 0, rb_block_proc());