summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-09 05:19:18 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-09 05:19:18 +0000
commit3cfa84d562d85f4ba8e4ad2aea08ef606c9b68a5 (patch)
tree5b0094821ca871299286f6cb8f374009a6f17371 /test
parent3a38b3c5d101ddd5715e9ac0f256426ce5dd58e0 (diff)
Allow `-> do rescue; end` as well as `proc do rescue; end`
https://twitter.com/takiuchi/status/950593389963051008 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index e85d6b545f..57ce169cd3 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1128,6 +1128,24 @@ eom
assert_equal(:begin, result)
end
+ def test_rescue_do_end_ensure_in_lambda
+ result = []
+ eval("#{<<-"begin;"}\n#{<<-"end;"}")
+ begin;
+ -> do
+ result << :begin
+ raise "An exception occurred!"
+ rescue
+ result << :rescue
+ else
+ result << :else
+ ensure
+ result << :ensure
+ end.call
+ end;
+ assert_equal([:begin, :rescue, :ensure], result)
+ end
+
def test_return_in_loop
obj = Object.new
def obj.test