summaryrefslogtreecommitdiff
path: root/test/ruby/test_keyword.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-26 01:24:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-26 01:24:52 +0000
commitc07d78eb0e8e9d3a8f9e8c860b362964157ff43a (patch)
treefb070b46cc783fb2d8d9fd40141dbd7607d6e872 /test/ruby/test_keyword.rb
parent47809f09346a7a026b56635bf7a2b84069fbbe39 (diff)
parse.y: keyword argument without paren
* parse.y (IS_LABEL_POSSIBLE): allow labels for keyword arguments just after method definition without a parenthesis. [ruby-core:52820] [Bug #7942] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r--test/ruby/test_keyword.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 3685024991..66f9cc8dbb 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -274,4 +274,20 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_valid_syntax("def bug7662(*, **) end")
assert_valid_syntax("def bug7662(a, **) end")
end
+
+ def test_without_paren
+ bug7942 = '[ruby-core:52820] [Bug #7942]'
+ assert_valid_syntax("def bug7942 a: 1; end")
+ assert_valid_syntax("def bug7942 a: 1, **; end")
+
+ o = Object.new
+ eval("def o.bug7942 a: 1; a; end", nil, __FILE__, __LINE__)
+ assert_equal(1, o.bug7942(), bug7942)
+ assert_equal(42, o.bug7942(a: 42), bug7942)
+
+ o = Object.new
+ eval("def o.bug7942 a: 1, **; a; end", nil, __FILE__, __LINE__)
+ assert_equal(1, o.bug7942(), bug7942)
+ assert_equal(42, o.bug7942(a: 42), bug7942)
+ end
end