diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-26 20:48:21 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-26 20:48:21 +0000 |
commit | 9245e097ecf201f0f5eaeff307b1403d97c2318b (patch) | |
tree | 849596b8af99adbef2ecff5d769928b33d3e5048 /spec/ruby/language/rescue_spec.rb | |
parent | 6c2b58986508b82896eefeaf195be0aa506eaa45 (diff) | |
download | ruby-9245e097ecf201f0f5eaeff307b1403d97c2318b.tar.gz |
Update to ruby/spec@a585ec3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/language/rescue_spec.rb')
-rw-r--r-- | spec/ruby/language/rescue_spec.rb | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb index 66a493cd34..5336265775 100644 --- a/spec/ruby/language/rescue_spec.rb +++ b/spec/ruby/language/rescue_spec.rb @@ -195,26 +195,34 @@ describe "The rescue keyword" do ScratchPad.recorded.should == [:one, :else_ran, :ensure_ran, :outside_begin] end - else_without_rescue = lambda { - eval <<-ruby - begin - ScratchPad << :begin - else - ScratchPad << :else - end - ruby - } - - ruby_version_is ""..."2.6" do + ruby_version_is ''...'2.6' do it "will execute an else block even without rescue and ensure" do - else_without_rescue.should complain(/else without rescue is useless/) + lambda { + eval <<-ruby + begin + ScratchPad << :begin + else + ScratchPad << :else + end + ruby + }.should complain(/else without rescue is useless/) ScratchPad.recorded.should == [:begin, :else] end end - ruby_version_is "2.6" do - else_without_rescue.should raise_error(SyntaxError) + ruby_version_is '2.6' do + it "raises SyntaxError when else is used without rescue and ensure" do + lambda { + eval <<-ruby + begin + ScratchPad << :begin + else + ScratchPad << :else + end + ruby + }.should raise_error(SyntaxError, /else without rescue is useless/) + end end it "will not execute an else block if an exception was raised" do |