From 89f38ed1502004ccf79a1327e6446a01140e73f2 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 16 Mar 2016 14:10:27 +0000 Subject: parse.y: symbol literals for alias/undef * defs/keywords (alias, undef): symbol literals are allowed. * parse.y (parse_percent): should parse symbol literals for alias and undef. [ruby-dev:47681] [Bug #8851] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_syntax.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/ruby/test_syntax.rb') diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 81a0f6e102..4f2a95c8c3 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -790,6 +790,30 @@ eom end end + def test_alias_symbol + bug8851 = '[ruby-dev:47681] [Bug #8851]' + formats = ['%s', ":'%s'", ':"%s"', '%%s(%s)'] + all_assertions(bug8851) do |all| + formats.product(formats) do |form1, form2| + all.for(code = "alias #{form1 % 'a'} #{form2 % 'p'}") do + assert_valid_syntax(code) + end + end + end + end + + def test_undef_symbol + bug8851 = '[ruby-dev:47681] [Bug #8851]' + formats = ['%s', ":'%s'", ':"%s"', '%%s(%s)'] + all_assertions(bug8851) do |all| + formats.product(formats) do |form1, form2| + all.for(code = "undef #{form1 % 'a'}, #{form2 % 'p'}") do + assert_valid_syntax(code) + end + end + end + end + private def not_label(x) @result = x; @not_label ||= nil end -- cgit v1.2.3