summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-24 07:04:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-24 07:04:41 +0000
commit5f34227718b20c1f7b10798ff2180629a391e1a8 (patch)
tree7798584ee9cff43c0d4ceaa1054e0db2e33c5ea5 /test
parent4f2b00429e9f98a91ae94f10d2d0435a120ed5e7 (diff)
* parse.y (parser_yylex): EXPR_BEG by keywords is a start point of
commands. [ruby-dev:45563][Bug #6347] * parse.y (superclass): ditto for superclass. * parse.y (parser_parse_string, parser_here_document): ditto for string interpolation. * parse.y (parser_yylex): ditto for singleton class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 51a0f355f8..af795440c5 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -103,8 +103,40 @@ class TestSyntax < Test::Unit::TestCase
end
end
+ def test_cmd_symbol_after_keyword
+ bug6347 = '[ruby-dev:45563]'
+ assert_not_label(:foo, 'if true then not_label:foo end', bug6347)
+ assert_not_label(:foo, 'if false; else not_label:foo end', bug6347)
+ assert_not_label(:foo, 'begin not_label:foo end', bug6347)
+ assert_not_label(:foo, 'begin ensure not_label:foo end', bug6347)
+ end
+
+ def test_cmd_symbol_in_string
+ bug6347 = '[ruby-dev:45563]'
+ assert_not_label(:foo, '"#{not_label:foo}"', bug6347)
+ end
+
+ def test_cmd_symbol_singleton_class
+ bug6347 = '[ruby-dev:45563]'
+ @not_label = self
+ assert_not_label(:foo, 'class << not_label:foo; end', bug6347)
+ end
+
+ def test_cmd_symbol_superclass
+ bug6347 = '[ruby-dev:45563]'
+ @not_label = Object
+ assert_not_label(:foo, 'class Foo < not_label:foo; end', bug6347)
+ end
+
private
+ def not_label(x) @result = x; @not_label ||= nil end
+ def assert_not_label(expected, src, message = nil)
+ @result = nil
+ assert_nothing_raised(SyntaxError, message) {eval(src)}
+ assert_equal(expected, @result, message)
+ end
+
def make_tmpsrc(f, src)
f.open
f.truncate(0)