diff options
Diffstat (limited to 'spec/ruby/language/rescue_spec.rb')
-rw-r--r-- | spec/ruby/language/rescue_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb index 281bb8fde8..d7042b7973 100644 --- a/spec/ruby/language/rescue_spec.rb +++ b/spec/ruby/language/rescue_spec.rb @@ -291,10 +291,20 @@ describe "The rescue keyword" do 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 |