From 4e71ea3a1ae284b6ba2d0ef210666c491f24e1c9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 18 May 2014 15:36:58 +0000 Subject: merge revision(s) r45405,r45408: [Backport #9669] [Backport #9740] * parse.y (lex_state_e, parser_params, f_arglist, parser_yylex): separate EXPR_LABELARG from EXPR_BEG and let newline significant, so that required keyword argument can place at the end of argument list without parentheses. [ruby-core:61658] [Bug #9669] * parse.y (parser_yylex): only a newline after label should be significant. [ruby-core:61658] [Bug #9669] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_keyword.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 03b93dbf0d..f6b4048d61 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -325,6 +325,25 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([[:keyreq, :a], [:keyrest, :b]], o.method(:bar).parameters, feature7701) assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar(c: bug8139)} assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar} + + bug9669 = '[ruby-core:61658] [Bug #9669]' + assert_nothing_raised(SyntaxError, bug9669) do + eval(<<-'end;', nil, __FILE__, __LINE__) + def bug9669.foo a: + return a + end + end; + end + assert_equal(42, bug9669.foo(a: 42)) + assert_nothing_raised(SyntaxError, bug9669) do + eval(<<-'end;', nil, __FILE__, __LINE__) + o = { + a: + 1 + } + end; + end + assert_equal({a: 1}, o, bug9669) end def test_block_required_keyword -- cgit v1.2.3