summaryrefslogtreecommitdiff
path: root/test/ruby/test_settracefunc.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-29 07:50:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-29 07:50:27 +0000
commite26c2bc21baac04ab52bff4eeedd9f41e4cb1f31 (patch)
treecaf89974265b2d39ab74bf784009f0b52a4f8b4c /test/ruby/test_settracefunc.rb
parentb0c4ac77799fdf60a489f9e735158647c630865a (diff)
vm_trace.c: trace_func safe level check
* vm_trace.c (set_trace_func, thread_{add,set}_trace_func_m): check safe level as well as 1.8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_settracefunc.rb')
-rw-r--r--test/ruby/test_settracefunc.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index af976514937..264b805127d 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -397,6 +397,38 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal(self, ok, bug3921)
end
+ def assert_security_error_safe4
+ func = lambda {
+ $SAFE = 4
+ proc {yield}
+ }.call
+ assert_raise(SecurityError, &func)
+ end
+
+ def test_set_safe4
+ assert_security_error_safe4 do
+ set_trace_func(lambda {|*|})
+ end
+ end
+
+ def test_thread_set_safe4
+ th = Thread.start {sleep}
+ assert_security_error_safe4 do
+ th.set_trace_func(lambda {|*|})
+ end
+ ensure
+ th.kill
+ end
+
+ def test_thread_add_safe4
+ th = Thread.start {sleep}
+ assert_security_error_safe4 do
+ th.add_trace_func(lambda {|*|})
+ end
+ ensure
+ th.kill
+ end
+
class << self
define_method(:method_added, Module.method(:method_added))
end