Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions language/rescue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,20 @@ def rescuer.===(exception)
end.should == :expected
end

ruby_version_is ""..."2.4" do
it "fails when using 'rescue' in method arguments" do
lambda { eval '1.+ (1 rescue 1)' }.should raise_error(SyntaxError)
end
end

ruby_version_is "2.4" do
it "allows 'rescue' in method arguments" do
two = eval '1.+ (raise("Error") rescue 1)'
two.should == 2
end

it "requires the 'rescue' in method arguments to be wrapped in parens" do
lambda { eval '1.+(1 rescue 1)' }.should raise_error(SyntaxError)
end
end
end