mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: invalid name as mere string
* parse.y (parser_peek_variable_name): treat invalid global, class, and instance variable names as mere strings rather than errors. [ruby-core:54885] [Bug #8375] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0542f05b32
commit
ecddb96785
3 changed files with 98 additions and 32 deletions
|
@ -361,6 +361,17 @@ class TestParse < Test::Unit::TestCase
|
|||
assert_equal("foo 1 bar", "foo #$1 bar")
|
||||
end
|
||||
|
||||
def test_dstr_disallowd_variable
|
||||
bug8375 = '[ruby-core:54885] [Bug #8375]'
|
||||
%w[@ @1 @@. @@ @@1 @@. $ $%].each do |src|
|
||||
src = '#'+src+' '
|
||||
str = assert_nothing_raised(SyntaxError, "#{bug8375} #{src.dump}") do
|
||||
break eval('"'+src+'"')
|
||||
end
|
||||
assert_equal(src, str, bug8375)
|
||||
end
|
||||
end
|
||||
|
||||
def test_dsym
|
||||
assert_nothing_raised { eval(':""') }
|
||||
end
|
||||
|
@ -527,13 +538,14 @@ class TestParse < Test::Unit::TestCase
|
|||
)
|
||||
end
|
||||
|
||||
assert_raise(SyntaxError) do
|
||||
eval %q(
|
||||
assert_nothing_raised(SyntaxError) do
|
||||
x = eval %q(
|
||||
<<FOO
|
||||
#$
|
||||
FOO
|
||||
)
|
||||
end
|
||||
assert_equal "\#$\n", x
|
||||
|
||||
assert_raise(SyntaxError) do
|
||||
eval %Q(
|
||||
|
@ -553,14 +565,15 @@ FOO
|
|||
)
|
||||
end
|
||||
|
||||
assert_raise(SyntaxError) do
|
||||
eval %q(
|
||||
assert_nothing_raised(SyntaxError) do
|
||||
x = eval %q(
|
||||
<<FOO
|
||||
#$
|
||||
foo
|
||||
FOO
|
||||
)
|
||||
end
|
||||
assert_equal "\#$\nfoo\n", x
|
||||
|
||||
assert_nothing_raised do
|
||||
eval "x = <<""FOO\r\n1\r\nFOO"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue