summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_file.rb2
-rw-r--r--test/ruby/test_optimization.rb2
-rw-r--r--test/ruby/test_proc.rb24
-rw-r--r--test/ruby/test_require.rb2
-rw-r--r--test/ruby/test_thread.rb6
5 files changed, 24 insertions, 12 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index 2aa145a303..9f09ac6fd1 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -465,6 +465,8 @@ class TestFile < Test::Unit::TestCase
(0..1).each do |level|
assert_nothing_raised(SecurityError, bug5374) {in_safe[level]}
end
+ ensure
+ $SAFE = 0
end
if /(bcc|ms|cyg)win|mingw|emx/ =~ RUBY_PLATFORM
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index 11cf1ffbfb..dc542b644e 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -677,7 +677,7 @@ class TestRubyOptimization < Test::Unit::TestCase
$SAFE = 1
b.call
end
- assert_equal 0, foo{$SAFE}
+ assert_equal 1, foo{$SAFE}
END
end
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 1a1ca24228..1607baf067 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -160,26 +160,34 @@ class TestProc < Test::Unit::TestCase
$SAFE += 1
proc {$SAFE}
}.call
- assert_equal(safe, $SAFE)
+
+ assert_equal(safe + 1, $SAFE)
assert_equal(safe + 1, p.call)
- assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, $SAFE)
+ $SAFE = 0
c.class_eval {define_method(:safe, p)}
assert_equal(safe, x.safe)
- assert_equal(safe, x.method(:safe).call)
- assert_equal(safe, x.method(:safe).to_proc.call)
+ $SAFE = 0
p = proc {$SAFE += 1}
assert_equal(safe + 1, p.call)
- assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, $SAFE)
+ $SAFE = 0
c.class_eval {define_method(:inc, p)}
assert_equal(safe + 1, proc {x.inc; $SAFE}.call)
- assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, $SAFE)
+
+ $SAFE = 0
assert_equal(safe + 1, proc {x.method(:inc).call; $SAFE}.call)
- assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, $SAFE)
+
+ $SAFE = 0
assert_equal(safe + 1, proc {x.method(:inc).to_proc.call; $SAFE}.call)
- assert_equal(safe, $SAFE)
+ assert_equal(safe + 1, $SAFE)
+ ensure
+ $SAFE = 0
end
def m2
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index 28cf686a26..af8e6e30fa 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -112,6 +112,8 @@ class TestRequire < Test::Unit::TestCase
proc do |require_path|
$SAFE = 1
require(require_path)
+ ensure
+ $SAFE = 0
end
end
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 591292962d..cf3eefa25f 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -505,10 +505,10 @@ class TestThread < Test::Unit::TestCase
sleep
end
Thread.pass until ok
- assert_equal(0, Thread.current.safe_level)
- assert_equal(1, t.safe_level)
-
+ assert_equal($SAFE, Thread.current.safe_level)
+ assert_equal($SAFE, t.safe_level)
ensure
+ $SAFE = 0
t.kill if t
end