[前][次][番号順一覧][スレッド一覧]

ruby-changes:26920

From: nobu <ko1@a...>
Date: Tue, 29 Jan 2013 17:58:13 +0900 (JST)
Subject: [ruby-changes:26920] nobu:r38972 (trunk): test_settracefunc.rb: fix tests

nobu	2013-01-29 17:58:04 +0900 (Tue, 29 Jan 2013)

  New Revision: 38972

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38972

  Log:
    test_settracefunc.rb: fix tests
    
    * test/ruby/test_settracefunc.rb (assert_security_error_safe4): fix
      tests to set $SAFE separatedly

  Modified files:
    trunk/test/ruby/test_settracefunc.rb

Index: test/ruby/test_settracefunc.rb
===================================================================
--- test/ruby/test_settracefunc.rb	(revision 38971)
+++ test/ruby/test_settracefunc.rb	(revision 38972)
@@ -397,34 +397,38 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L397
     assert_equal(self, ok, bug3921)
   end
 
-  def assert_security_error_safe4
-    func = lambda {
-      $SAFE = 4
-      proc {yield}
-    }.call
-    assert_raise(SecurityError, &func)
+  def assert_security_error_safe4(block)
+    assert_raise(SecurityError) do
+      block.call
+    end
   end
 
   def test_set_safe4
-    assert_security_error_safe4 do
+    func = proc do
+      $SAFE = 4
       set_trace_func(lambda {|*|})
     end
+    assert_security_error_safe4(func)
   end
 
   def test_thread_set_safe4
     th = Thread.start {sleep}
-    assert_security_error_safe4 do
+    func = proc do
+      $SAFE = 4
       th.set_trace_func(lambda {|*|})
     end
+    assert_security_error_safe4(func)
   ensure
     th.kill
   end
 
   def test_thread_add_safe4
     th = Thread.start {sleep}
-    assert_security_error_safe4 do
+    func = proc do
+      $SAFE = 4
       th.add_trace_func(lambda {|*|})
     end
+    assert_security_error_safe4(func)
   ensure
     th.kill
   end
@@ -922,15 +926,19 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L926
 
   def test_trace_point_enable_safe4
     tp = TracePoint.new {}
-    assert_security_error_safe4 do
+    func = proc do
+      $SAFE = 4
       tp.enable
     end
+    assert_security_error_safe4(func)
   end
 
   def test_trace_point_disable_safe4
     tp = TracePoint.new {}
-    assert_security_error_safe4 do
+    func = proc do
+      $SAFE = 4
       tp.disable
     end
+    assert_security_error_safe4(func)
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]