Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
adapted throw specs to use UncaughtThrowError for non catched throw
  • Loading branch information
tak1n committed May 25, 2015
1 parent 235ee06 commit 95ab59b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions spec/ruby/core/kernel/catch_spec.rb
Expand Up @@ -30,12 +30,12 @@
ScratchPad.recorded.should == :thrown_key
end

it "raises an ArgumentError if a Symbol is thrown for a String catch value" do
lambda { catch("exit") { throw :exit } }.should raise_error(ArgumentError)
it "raises an UncaughtThrowError if a Symbol is thrown for a String catch value" do
lambda { catch("exit") { throw :exit } }.should raise_error(UncaughtThrowError)
end

it "raises an ArgumentError if a String with different identity is thrown" do
lambda { catch("exit") { throw "exit" } }.should raise_error(ArgumentError)
it "raises an UncaughtThrowError if a String with different identity is thrown" do
lambda { catch("exit") { throw "exit" } }.should raise_error(UncaughtThrowError)
end

it "catches a Symbol when thrown a matching Symbol" do
Expand Down
12 changes: 6 additions & 6 deletions spec/ruby/language/throw_spec.rb
Expand Up @@ -44,7 +44,7 @@
end

it "does not convert strings to a symbol" do
lambda { catch(:exit) { throw "exit" } }.should raise_error(ArgumentError)
lambda { catch(:exit) { throw "exit" } }.should raise_error(UncaughtThrowError)
end

it "unwinds stack from within a method" do
Expand All @@ -62,18 +62,18 @@ def throw_method(handler,val)
catch(:foo) { c.call }.should == :msg
end

it "raises an ArgumentError if outside of scope of a matching catch" do
lambda { throw :test,5 }.should raise_error(ArgumentError)
lambda { catch(:different) { throw :test,5 } }.should raise_error(ArgumentError)
it "raises an UncaughtThrowError if outside of scope of a matching catch" do
lambda { throw :test,5 }.should raise_error(UncaughtThrowError)
lambda { catch(:different) { throw :test,5 } }.should raise_error(UncaughtThrowError)
end

it "raises an ArgumentError if used to exit a thread" do
it "raises an UncaughtThrowError if used to exit a thread" do
lambda {
catch(:what) do
Thread.new do
throw :what
end.join
end
}.should raise_error(ArgumentError)
}.should raise_error(UncaughtThrowError)
end
end
16 changes: 8 additions & 8 deletions spec/ruby/optional/capi/kernel_spec.rb
Expand Up @@ -87,8 +87,8 @@
ScratchPad.recorded.should == [:before_throw]
end

it "raises an ArgumentError if there is no catch block for the symbol" do
lambda { @s.rb_throw(nil) }.should raise_error(ArgumentError)
it "raises an UncaughtThrowError if there is no catch block for the symbol" do
lambda { @s.rb_throw(nil) }.should raise_error(UncaughtThrowError)
end
end

Expand All @@ -113,8 +113,8 @@
ScratchPad.recorded.should == [:before_throw]
end

it "raises an ArgumentError if there is no catch block for the symbol" do
lambda { @s.rb_throw(nil) }.should raise_error(ArgumentError)
it "raises an UncaughtThrowError if there is no catch block for the symbol" do
lambda { @s.rb_throw(nil) }.should raise_error(UncaughtThrowError)
end
end

Expand Down Expand Up @@ -296,8 +296,8 @@
ScratchPad.recorded.should == [:before_throw]
end

it "raises an ArgumentError if the throw symbol isn't caught" do
lambda { @s.rb_catch("foo", lambda { throw :bar }) }.should raise_error(ArgumentError)
it "raises an UncaughtThrowError if the throw symbol isn't caught" do
lambda { @s.rb_catch("foo", lambda { throw :bar }) }.should raise_error(UncaughtThrowError)
end
end

Expand All @@ -322,8 +322,8 @@
ScratchPad.recorded.should == [:before_throw]
end

it "raises an ArgumentError if the throw symbol isn't caught" do
lambda { @s.rb_catch("foo", lambda { throw :bar }) }.should raise_error(ArgumentError)
it "raises an UncaughtThrowError if the throw symbol isn't caught" do
lambda { @s.rb_catch("foo", lambda { throw :bar }) }.should raise_error(UncaughtThrowError)
end
end

Expand Down

0 comments on commit 95ab59b

Please sign in to comment.