Skip to content
Browse files

Add more specs for Thread#raise with no arg inside rescue

  • Loading branch information...
1 parent fd6fcea commit 788a5b0d99ef7b96b49e36ac0a4e1b8f835052f7 @ryoqun committed Oct 4, 2012
Showing with 89 additions and 4 deletions.
  1. +89 −4 spec/ruby/core/thread/raise_spec.rb
View
93 spec/ruby/core/thread/raise_spec.rb
@@ -52,13 +52,32 @@
lambda { t.value }.should raise_error(RuntimeError)
end
+ ruby_version_is "" ... "1.9" do
+ it "raises a ZeroDivisionError when called with no arguments inside rescue" do
+ t = Thread.new do
+ begin
+ 1/0
+ rescue ZeroDivisionError
+ sleep
+ end
+ end
+ begin
+ raise RangeError
+ rescue
+ ThreadSpecs.spin_until_sleeping(t)
+ t.raise
+ end
+ lambda {t.value}.should raise_error(ZeroDivisionError)
+ end
+ end
+
ruby_version_is "1.9" do
- it "raises a RuntimeError when called with no arguments" do
+ it "raises a RuntimeError when called with no arguments inside rescue" do
t = Thread.new do
begin
1/0
rescue ZeroDivisionError
- sleep 3
+ sleep
end
end
begin
@@ -68,7 +87,6 @@
t.raise
end
lambda {t.value}.should raise_error(RuntimeError)
- t.kill
end
end
end
@@ -127,14 +145,81 @@
begin
raise "Create an active exception for the current thread too"
rescue
- Thread.pass until raised || !t.alive?
+ Thread.pass until raised
t.raise RangeError
lambda {t.value}.should raise_error(RangeError)
end
end
+ ruby_version_is "" ... "1.9" do
+ it "raises a ZeroDivisionError when called with no arguments inside rescue" do
+ raised = false
+ t = Thread.new do
+ begin
+ 1/0
+ rescue ZeroDivisionError
+ raised = true
+ loop { }
+ end
+ end
+ begin
+ raise RangeError
+ rescue
+ Thread.pass until raised
+ t.raise
+ end
+ lambda {t.value}.should raise_error(ZeroDivisionError)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when called with no arguments inside rescue" do
+ raised = false
+ t = Thread.new do
+ begin
+ 1/0
+ rescue ZeroDivisionError
+ raised = true
+ loop { }
+ end
+ end
+ begin
+ raise RangeError
+ rescue
+ Thread.pass until raised
+ t.raise
+ end
+ lambda {t.value}.should raise_error(RuntimeError)
+ end
+ end
end
describe "Thread#raise on same thread" do
it_behaves_like :kernel_raise, :raise, Thread.current
+
+ ruby_version_is "" ... "1.9" do
+ it "raises a ZeroDivisionError when called with no arguments inside rescue" do
+ t = Thread.new do
+ begin
+ 1/0
+ rescue ZeroDivisionError
+ Thread.current.raise
+ end
+ end
+ lambda {t.value}.should raise_error(ZeroDivisionError)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when called with no arguments inside rescue" do
+ t = Thread.new do
+ begin
+ 1/0
+ rescue ZeroDivisionError
+ Thread.current.raise
+ end
+ end
+ lambda {t.value}.should raise_error(RuntimeError)
+ end
+ end
end

0 comments on commit 788a5b0

Please sign in to comment.
Something went wrong with that request. Please try again.