mirror of
https://github.com/ruby/ruby.git
synced 2025-08-27 15:06:10 +02:00
parse.y: no punctuation instance/class variables
* parse.y (parse_atmark): exclude punctuation follows @ marks, whereas it is inclusive after $ mark as some punctuation global variables exist. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
277af37b42
commit
9800fc26b0
3 changed files with 12 additions and 9 deletions
|
@ -376,23 +376,25 @@ class TestParse < Test::Unit::TestCase
|
|||
assert_nothing_raised { eval(':""') }
|
||||
end
|
||||
|
||||
def assert_disallowed_variable(type, noname, *invalid)
|
||||
assert_syntax_error("a = #{noname}", "`#{noname}' without identifiers is not allowed as #{type} variable name")
|
||||
def assert_disallowed_variable(type, noname, invalid)
|
||||
noname.each do |name|
|
||||
assert_syntax_error("a = #{name}", "`#{noname[0]}' without identifiers is not allowed as #{type} variable name")
|
||||
end
|
||||
invalid.each do |name|
|
||||
assert_syntax_error("a = #{name}", "`#{name}' is not allowed as #{type} variable name")
|
||||
end
|
||||
end
|
||||
|
||||
def test_disallowed_instance_variable
|
||||
assert_disallowed_variable("an instance", *%w[@ @1 @.])
|
||||
assert_disallowed_variable("an instance", %w[@ @.], %w[@1])
|
||||
end
|
||||
|
||||
def test_disallowed_class_variable
|
||||
assert_disallowed_variable("a class", *%w[@@ @@1 @@.])
|
||||
assert_disallowed_variable("a class", %w[@@ @@.], %w[@@1])
|
||||
end
|
||||
|
||||
def test_disallowed_gloal_variable
|
||||
assert_disallowed_variable("a global", *%w[$ $%])
|
||||
assert_disallowed_variable("a global", %w[$], %w[$%])
|
||||
end
|
||||
|
||||
def test_arg2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue